Improved comments.

This commit is contained in:
L. Kärkkäinen 2020-03-20 17:42:28 +02:00
parent 68fb963539
commit 1580ca637f

View File

@ -30,12 +30,14 @@ else:
def ctrlc_workaround_for_windows(app):
async def stay_active(app):
"""Frequently poll asyncio to allow *receiving* any signals in Python"""
"""Asyncio wakeups to allow receiving SIGINT in Python"""
loop = asyncio.get_running_loop()
while not die:
# If someone else stopped the app, just exit
if getattr(loop, "_stopping", False):
return
# Windows Python blocks signal handlers while the event loop is
# waiting for I/O. Frequent wakeups keep interrupts flowing.
await asyncio.sleep(0.1)
# Can't be called from signal handler, so call it from here
app.stop()