Allow applications to handle KeyboardInterrupt
- Lenguaje dominante
- Python
- Estrellas
- 2.5k
- Forks
- 260
- Merge medio
- 2 d 8 h
- PR fusionados (30 d)
- 19
Descripción
Currently the behavior between trio vs asyncio/curio differs in how ctrl+c is handled. Trio raises `KeyboardInterrupt` in the main task while asyncio and curio just clean up the tasks and exit. It would be preferable to unify the behavior across all backends so that at least applications using `anyio.run()` as their entry point could take advantage of this.
For asyncio and curio, this probably requires setting up a signal handler and raising the `KeyboardInterrupt` exception there. This will be particularly tricky on asyncio which, unlike curio, does not allow specific exceptions to be directly raised on tasks. It may require hijacking the coroutine object of the main task, much like what I did in [asyncio_extras](https://github.com/agronholm/asyncio_extras/blob/master/asyncio_extras/threads.py).
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.