[issue39622] KeyboardInterrupt is ignored when await asyncio.sleep(0)

Maor Kleinberger report at bugs.python.org
Thu Feb 20 13:43:19 EST 2020


Maor Kleinberger <kmaork at gmail.com> added the comment:

This behaved similarly on my machine, also ubuntu. But it also happened (less often) with small numbers, like sleep(0.0000000000000000000001).

Also, I tried it on my windows 10 and experienced another unexpected behavior - only when using sleep(0), Ctrl-C would not work *at all* from time to time. Most of the times it would stop the program immediately. This also happened when using 0.0000000000000000000001 instead of 0.

Unless 0.0000000000000000000001 turns into 0 somewhere along the way, I'd suspect that there is a piece of code inside asyncio's core that doesn't handle interrupting correctly (both on linux and windows), and using sleep with small numbers just makes it much more probable for this piece of code to be running when the Ctrl-C signal is sent.

I'll try to dig in more.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39622>
_______________________________________


More information about the Python-bugs-list mailing list