Avoid "RuntimeError: Event loop is closed"

Triggered by pytest now.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Jan Kiszka 2019-09-25 11:00:45 +02:00
parent e29035407f
commit 3ef3ac855e

View File

@ -95,8 +95,9 @@ def _atexit_handler():
"""
loop = asyncio.get_event_loop()
pending = asyncio.Task.all_tasks()
loop.run_until_complete(asyncio.gather(*pending))
loop.close()
if not loop.is_closed():
loop.run_until_complete(asyncio.gather(*pending))
loop.close()
def kas_get_argparser():