Merge pull request #5434 from freqtrade/fix_asyncio_exception

Fix no-event-loop available
This commit is contained in:
Matthias 2021-08-17 07:10:22 +02:00 committed by GitHub
commit 81715d0b9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,8 +32,11 @@ class UvicornServer(uvicorn.Server):
asyncio_setup()
else:
asyncio.set_event_loop(uvloop.new_event_loop())
try:
loop = asyncio.get_event_loop()
except RuntimeError:
# When running in a thread, we'll not have an eventloop yet.
loop = asyncio.new_event_loop()
loop.run_until_complete(self.serve(sockets=sockets))
@contextlib.contextmanager