Skip to content

Commit 18fa3bb

Browse files
authored
Set Windows event loop policy
1 parent 760f415 commit 18fa3bb

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

taskiq/cli/worker/run.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,14 @@ def interrupt_handler(signum: int, _frame: Any) -> None:
119119
signal.signal(signal.SIGTERM, interrupt_handler)
120120
if sys.platform != "win32":
121121
signal.signal(signal.SIGHUP, interrupt_handler)
122+
else:
123+
# Windows requires the selector event loop policy.
124+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
122125

123126
if uvloop is not None:
124127
logger.debug("UVLOOP found. Using it as async runner")
125128
loop = uvloop.new_event_loop() # type: ignore
126129
else:
127-
if sys.platform == "win32":
128-
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
129130
loop = asyncio.new_event_loop()
130131

131132
asyncio.set_event_loop(loop)

0 commit comments

Comments
 (0)