ipython / ipython/ipykernel

KeyboardInterrupts not caught in dispatch_shell

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

描述

The `pre_handler_hook` in `dispatch_shell` sets the SIGINT handler to raise a KeyboardInterrupt if the kernel receives a SIGINT: https://github.com/ipython/ipykernel/blob/master/ipykernel/kernelbase.py#L346

However, the `try/except` surrounding the `pre_handler_hook`, and the `try/except` immediately afterwards on line 349 will not catch a KeyboardInterrupt. `KeyboardInterrupt` is a subclass of `BaseException`, but not `Exception`.

The result is that if a user cancels a running command, and the SIGINT arrives after the `pre_handler_hook`, but before the `try/except` in `_run_cell` in `interactiveshell.py`: https://github.com/ipython/ipython/blob/master/IPython/core/interactiveshell.py#L2974 , the exception is not caught and the kernel crashes.

Can we update `dispatch_shell` to catch `BaseException`?

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

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

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