Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow applications to handle KeyboardInterrupt #148

Open
agronholm opened this issue Aug 16, 2020 · 2 comments
Open

Allow applications to handle KeyboardInterrupt #148

agronholm opened this issue Aug 16, 2020 · 2 comments
Labels
design Requires a design decision

Comments

@agronholm
Copy link
Owner

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.

@agronholm agronholm added the design Requires a design decision label Aug 16, 2020
@njsmith
Copy link
Collaborator

njsmith commented Aug 16, 2020

Note that Trio will probably switch to delivering some KeyboardInterrupts out of trio.run instead of inside the main task; see python-trio/trio#1537 and linked issues

@agronholm
Copy link
Owner Author

Ouch, what a complicated subject this is. I'd better defer any actions on this and just document the current status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Requires a design decision
Projects
None yet
Development

No branches or pull requests

2 participants