Uvloop: Ignoring KeyboardInterrupt

Created on 27 Oct 2019  路  4Comments  路  Source: MagicStack/uvloop

  • uvloop version: 0.14.0rc1
  • Python version: 3.7.4
  • Platform: Manjaro
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: Yes
  • Does uvloop behave differently from vanilla asyncio? How?: Vanilla loop respects the KeyboardInterrupt while uvloop ignore it.


Here is a code snippet:

import asyncio
from aiohttp import web
import uvloop

async def start(app: web.Application, host: str, port: int) -> web.AppRunner:
    """Start the server"""
    runner = web.AppRunner(app)
    await runner.setup()
    server = web.TCPSite(runner, host, port)
    await server.start()
    return runner

def main() -> None:
    """Entrypoint"""
    host = "0.0.0.0"
    port = 8000
    app = web.Application()
    loop = asyncio.get_event_loop()
    runner = loop.run_until_complete(start(app, host, port))
    print(f"======== Running on http://{host}:8000 ========\n" "(Press CTRL+C to quit)")
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        loop.run_until_complete(runner.cleanup())


if __name__ == "__main__":
    uvloop.install()
    main()

Execute the file:
python issue.py

Hit Ctrl+C.

The keyboard interrupt will be ignored. If you comment out line 28 uvloop.install() the interrupt is respected. This used to work fine, only noticed that it stopped working today.

bug fixed in master

All 4 comments

Seems that the regression was introduced in 48d376d30c9a01516f13d15aaa3d756ce13e97e8 cc @vladima

Alright, I think I know what causes the bug. Will need to refactor our signals setup/processing code a bit to untangle it. I'll release RC2 tomorrow or the day after with the fix.

Fixed in uvloop 0.14.0rc2. Thank you!

@1st1 I appreciate the quick turnaround. Keep up the great work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dyseo picture dyseo  路  8Comments

pranavtbhat picture pranavtbhat  路  6Comments

btegs picture btegs  路  6Comments

gaby picture gaby  路  4Comments

GoodPete picture GoodPete  路  8Comments