Skip to content

KeyboardInterrupt not handled correctly #296

@allefeld

Description

@allefeld

If I interrupt via Ctrl+C a long-running computation, here simulated by time.sleep, Jupyter Console gets confused:

$ jupyter console
Jupyter console 6.6.3

Python 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.15.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from time import sleep

In [2]: sleep(15)
^C
KeyboardInterrupt escaped interact()


In [3]: 2+2🤫/lib/python3.10/site-packages/jupyter_console/ptshell.py:787: UserWarning: The kernel did not respond to an is_complete_request. Setting `use_kernel_is_complete` to False.
  warn('The kernel did not respond to an is_complete_request. '
In [3]: 2+2

Out[3]: 4

🤫 replaces the path to my Conda environment.

By "confused" I mean:

  • First there is a cryptic message.
  • Then the next prompt appears, but apparently because the kernel hasn't actually stopped executing the previous code, a tab completeness check request is not responded to.
  • The second line, 2+2 is eventually executed, but there is a delay of several seconds before that.

I first encountered this problem with a Python wrapper kernel I'm developing, but then tested with the default Python kernel. The same thing happens in both, which leads me to believe that this is a bug in Jupyter Console. From what I can tell, the kernel is never notified about the interruption.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions