Skip to content
Snippets Groups Projects
Commit 5ccad033 authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Worker: close asyncio loop at end of run

This is required when using asyncio subprocesses, to properly clean up
certain things.
parent ed2e6097
No related branches found
No related tags found
No related merge requests found
......@@ -109,6 +109,7 @@ def main():
except:
log.exception('Uncaught exception!')
log.warning('Shutting down')
loop.close()
def construct_asyncio_loop() -> asyncio.AbstractEventLoop:
......@@ -119,10 +120,12 @@ def construct_asyncio_loop() -> asyncio.AbstractEventLoop:
if sys.platform == 'win32':
loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
else:
loop = asyncio.get_event_loop()
if loop.is_closed():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
return loop
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment