agronholm / agronholm/anyio

Allow applications to handle KeyboardInterrupt

オープン
#148 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る
design
主要言語
Python
スター
2.5k
フォーク
260
平均マージ
2日 8時間
マージ済み PR(30日)
19

説明

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 を短くまとめたダイジェスト。