agronholm / agronholm/anyio

Allow applications to handle KeyboardInterrupt

未关闭
#148 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
design
主要语言
Python
星标
2.5k
派生
260
平均合并
1 天 8 小时
30 天内合并 PR
17

描述

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).

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。