Fix: There is no current event loop in thread

This commit is contained in:
Heiner Lohaus
2023-10-02 06:47:07 +02:00
parent 2dbeb54608
commit d116f04322
5 changed files with 41 additions and 27 deletions

View File

@@ -21,7 +21,11 @@ def get_event_loop() -> AbstractEventLoop:
try:
asyncio.get_running_loop()
except RuntimeError:
return asyncio.get_event_loop()
try:
return asyncio.get_event_loop()
except RuntimeError:
asyncio.set_event_loop(asyncio.new_event_loop())
return asyncio.get_event_loop()
try:
event_loop = asyncio.get_event_loop()
if not hasattr(event_loop.__class__, "_nest_patched"):