Skip to content

Commit 90df7fa

Browse files
committed
Use more_itertools.flatten
1 parent 07e576e commit 90df7fa

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ cryptography = ">=42.0.0"
5151
# https://github.com/apify/apify-sdk-python/issues/348
5252
httpx = "~0.27.0"
5353
lazy-object-proxy = ">=1.10.0"
54+
more_itertools = ">=10.2.0"
5455
scrapy = { version = ">=2.11.0", optional = true }
5556
typing-extensions = ">=4.1.0"
5657
websockets = ">=10.0 <14.0.0"

src/apify/_actor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import os
55
import sys
66
from datetime import timedelta
7-
from itertools import chain
87
from typing import TYPE_CHECKING, Any, Callable, TypeVar, cast
98

109
from lazy_object_proxy import Proxy
10+
from more_itertools import flatten
1111
from pydantic import AliasChoices
1212

1313
from apify_client import ApifyClientAsync
@@ -856,10 +856,10 @@ async def reboot(
856856
# Typically, crawlers are listening for the MIIGRATING event to stop processing new requests.
857857
# We can't just emit the events and wait for all listeners to finish,
858858
# because this method might be called from an event listener itself, and we would deadlock.
859-
persist_state_listeners = chain.from_iterable(
859+
persist_state_listeners = flatten(
860860
(self._event_manager._listeners_to_wrappers[Event.PERSIST_STATE] or {}).values() # noqa: SLF001
861861
)
862-
migrating_listeners = chain.from_iterable(
862+
migrating_listeners = flatten(
863863
(self._event_manager._listeners_to_wrappers[Event.MIGRATING] or {}).values() # noqa: SLF001
864864
)
865865

0 commit comments

Comments
 (0)