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

Maor Kleinberger report at bugs.python.org
Thu Feb 20 15:20:31 EST 2020


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

I wrote a small script that checks the behavior of asyncio.sleep when called with small amounts of time (starting from 0). For each amount I checked 500 times whether SleepTest has stopped when interrupted with SIGINT. Below are the results:

SLEEP TIME  SIGINT FAILURE PERCENT
0           26.6%
1e-06       9.8%
2e-06       11.8%
3e-06       11.2%
4e-06       9.6%
5e-06       13.8%
6e-06       5.6%
7e-06       2.6%
8e-06       1.4%
9e-06       1.6%
1e-05       2.2%
1.1e-05     2.2%
1.2e-05     2.0%
1.3e-05     1.8%
1.4e-05     0.8%

It is worth mentioning that the failure amount increased when my CPU was busier. Maybe it is because of false positives in my script (although I think I used relatively generous timeouts when waiting for the ioloop to start running and for the process to die after a SIGINT) and maybe it is because of the nature of the bug in asyncio. I didn't put a lot of effort into distinguishing between the two, as increasing the timeouts also made my CPU less busy.

Anyway, there is definitely a weird behavior here, and I still think there is a specific piece of code in asyncio that's causing it. Maybe I'll look at the code a bit, or try to think of other ways to approach this.

----------

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


More information about the Python-bugs-list mailing list