Interrupt on swallowed `KeyboardInterrupt` exceptions (`SIGINT`) when pressing twice (within 5 seconds)
@Carreau is already working on this.
Since Aug 26, 2026.
Assessment
This issue has not been assessed yet.
Description
Consider
import time
while True:
try:
time.sleep(1)
except BaseException:
pass
It is impossible to interrupt. But it does not have to be! With Python 3.12 we now have sys.monitoring and could instead show:
The running code caught the interrupt and kept going. Interrupt again within 5 seconds to force it to stop.
Current behaviour:
https://github.com/user-attachments/assets/aa51f4cc-afb3-4d6b-9d4f-cc32361417a3
Proposed behaviour:
https://github.com/user-attachments/assets/f5e891d1-fa78-4c7a-87af-ff0d3458c146
This would be similar to what jupyter-server does for interrupts with Ctrl + C (pressing it twice forces shutdown).
- Dominant language
- Python
- Stars
- 734
- Forks
- 411
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 8
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.
More from ipython/ipykernel
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 4/5 3-5 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 66/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
All issues in ipython/ipykernel
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100