python-trio / python-trio/trio
How should shielding interact with restrict_keyboard_interrupt_to_checkpoints?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
Right now KeyboardInterrupt can (if using the default handler) arrive anywhere; restrict_keyboard_interrupt_to_checkpoints=True makes it so it can only arrive at checkpoints. But in principle it can arrive at any checkpoint. In practice it currently only arrives at checkpoints inside the main task, which usually is going to be sitting in supervisor code. And currently it ignores shield=True scopes – you can get KeyboardInterrupted even if you're shielded against Cancelled.
The nursery clean-up code is prepared to handle this correctly, and that's what the main task will be doing in most cases, so this isn't super urgent. But it is surprising, maybe? Is it correct?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in trio/_core/_run.py, especially the nursery clean-up code around lines 319-326, and trace how restrict_keyboard_interrupt_to_checkpoints and shield=True affect checkpoint handling. Resolve the intended interaction between KeyboardInterrupt and shielding, then add or update coverage for the agreed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100