Skip to content

Commit 7c7fa84

Browse files
authored
Add get_event_loop_policy() to all get_event_loop() calls (#415)
* add support for python3.11 * update to setup-python v4 * add 3.11 to tox.ini * bump to 0.9.2 in preparation of next release * fix dumb merge * lint everything * set aiohttp minimum to 3.8.3 and mode-streaming minimum to 0.3.0 * add removed test classes from mode into tests.helpers * fix streams and topics tests * just add rc0 i stopping caring lol * add forgotten defs * fix imports * fix more dumb imports * just import AsyncMock from tests.helpers for now * add more checks for 3.10 and 3.11 * fix typo * add 3.11 to envlist * include custom Mock class to fix this absurd test * fix asyncmock import * remove unneeded import * fix import * fix import * neverending import issues * too many conftests * fix test_replies so it doesnt hang anymore * fix cache tests * coro be gone * add AsyncMock to __all__ * remove call.coro since deprecated behavior * test_worker.py passes now * basic fix for test agent * fix test_agent.py * update test_base.py * fix more tests * keep trying... * Add get_event_loop_policy() to all get_event_loop() calls * remove loop kwarg due to deprecation in 0.8.0 * more remaining tests as needs fixing * fix formatting * fix formatting... again * fix imports in test_events.py * fix AsyncMock imports * please let this be the last import fix * change echoing function in streams.py for py 3.11 compatibility * ensure futures for test_replies.py * ensure table recovery futures * ensure futures for all echo cors
1 parent cf397bc commit 7c7fa84

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

faust/cli/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ def __call__(self, *args: Any, **kwargs: Any) -> NoReturn:
621621

622622
def run_using_worker(self, *args: Any, **kwargs: Any) -> NoReturn:
623623
"""Execute command using :class:`faust.Worker`."""
624-
loop = asyncio.get_event_loop()
624+
loop = asyncio.get_event_loop_policy().get_event_loop()
625625
args = self.args + args
626626
kwargs = {**self.kwargs, **kwargs}
627627
service = self.as_service(loop, *args, **kwargs)
@@ -640,7 +640,7 @@ def as_service(
640640
return Service.from_awaitable(
641641
self.execute(*args, **kwargs),
642642
name=type(self).__name__,
643-
loop=loop or asyncio.get_event_loop(),
643+
loop=loop or asyncio.get_event_loop_policy().get_event_loop(),
644644
)
645645

646646
def worker_for_service(
@@ -659,7 +659,7 @@ def worker_for_service(
659659
console_port=self.console_port,
660660
redirect_stdouts=self.redirect_stdouts or False,
661661
redirect_stdouts_level=self.redirect_stdouts_level,
662-
loop=loop or asyncio.get_event_loop(),
662+
loop=loop or asyncio.get_event_loop_policy().get_event_loop(),
663663
daemon=self.daemon,
664664
)
665665

faust/transport/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__(
6161
) -> None:
6262
self.url = url
6363
self.app = app
64-
self.loop = loop or asyncio.get_event_loop()
64+
self.loop = loop or asyncio.get_event_loop_policy().get_event_loop()
6565

6666
def create_consumer(self, callback: ConsumerCallback, **kwargs: Any) -> ConsumerT:
6767
"""Create new consumer."""

faust/transport/drivers/aiokafka.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ async def _create_topic(
14821482
topic,
14831483
partitions,
14841484
replication,
1485-
loop=asyncio.get_event_loop(),
1485+
loop=asyncio.get_event_loop_policy().get_event_loop(),
14861486
**kwargs,
14871487
)
14881488
try:

faust/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ async def start_worker(worker: Worker) -> None:
164164
await worker.start()
165165
166166
def manage_loop():
167-
loop = asyncio.get_event_loop()
167+
loop = asyncio.get_event_loop_policy().get_event_loop()
168168
worker = Worker(app, loop=loop)
169169
try:
170170
loop.run_until_complete(start_worker(worker)

0 commit comments

Comments
 (0)