ipython / ipython/ipykernel

KeyboardInterrupts not caught in dispatch_shell

Abierto
#666 0 comentarios 1 reacción 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
734
Forks
412
Merge medio
1 d 5 h
PR fusionados (30 d)
8

Descripción

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`?

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.