Open amackillop opened 4 years ago
I believe that the exception handler for an asyncio event loop should be a normal function, not a coroutine function. The documentation says it's just a callable.
Tried running your snippet, and I got many strange behaviors, such as haning or infinite loop of exception handlers, etc., even after changing the exception handler to just print messages as a non-coroutine function.
I think it's primarily because your are mixing loop.stop
and asyncio.create_task
during a single event loop tick, and the completion of those created tasks are not guaranteed because your code just waits for runner.cleanup()
.
If you want to keep using aiologger
, I'd suggest to use janus
to mediate the synchronous loop exception handler and a separate logger coroutine task.
Maybe you might be interested at my boilerplate wrapper, aiotools.server
.
PYTHONASYNCIODEBUG
in env?: Yesuvloop
, I get a runtime warning and the application hangs until I run akill -9
on the process id.Snippet:
issue.py
Run the file:
python issue.py
Then hit Ctrl+c on keyboard, output:
Which hangs until running
kill -9 <pid>
If you comment out
uvloop.install()
and follow the same steps, the program terminates as expected. Output: