ipython / ipython/ipykernel

Interrupt on swallowed `KeyboardInterrupt` exceptions (`SIGINT`) when pressing twice (within 5 seconds)

未關閉
#1,550 1 則留言 1 個 reaction 已指派 1 人 已被 @Carreau 認領 在 GitHub 檢視
主要語言
Python
星號
734
分支
412
平均合併
1 天 5 小時
30 天內合併 PR
8

描述

Consider

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

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。