Uvloop_helper should use "get_running_loop"

This commit is contained in:
Matthias 2021-12-31 13:01:13 +01:00
parent 550a1eef91
commit c9296dc9a0

View File

@ -47,7 +47,7 @@ class UvicornServer(uvicorn.Server):
else: else:
asyncio.set_event_loop(uvloop.new_event_loop()) asyncio.set_event_loop(uvloop.new_event_loop())
try: try:
loop = asyncio.get_event_loop() loop = asyncio.get_running_loop()
except RuntimeError: except RuntimeError:
# When running in a thread, we'll not have an eventloop yet. # When running in a thread, we'll not have an eventloop yet.
loop = asyncio.new_event_loop() loop = asyncio.new_event_loop()