Skip to content

Interrupting kernel can only be used once #2158

@CYHSM

Description

@CYHSM

Bug: Notebook Editor, Interactive Window, Editor cells

Steps to cause the bug to occur

  1. Open a jupyter notebook
  2. Run following example code in a cell:
import time
for i in range(0, 100):
    try:
        print(i)
        time.sleep(0.5)
    except KeyboardInterrupt:
        print('You stopped run i={} early'.format(i))
        print('Hit interrupt button again if you want to exit')
        time.sleep(0.5)
  1. Try to interrupt kernel (before loop is finished)

Actual behavior

The above loop finishes although kernel was interrupted. This is a special case which I use for interrupting some loops while not interrupting the full process (therefore the KeyboardInterrupt). However, when I use jupyter notebook I can just call interrupt twice when I want to leave the loop. After calling it once in vscode the button for interruption is greyed out and I see a loading bar on top, can't restart kernel in this case and have to close the notebook and reopen it to restart the kernel.

Expected behavior

It would be nice to have the ability to interrupt the kernel until the kernel is actually interrupted. This is probably only an issue if somebody uses "except KeyboardInterrupt" but if it is possible to fix would be nice. Thanks.

Your Jupyter and/or Python environment

Please provide as much info as you readily know

  • Jupyter server running: happens Local & Remote
  • Extension version: 2020.2.64397
  • VS Code version: 1.43
  • Setting python.jediEnabled: false
  • Python and/or Anaconda version: Python 3.7.6
  • OS: Linux (ubuntu):
  • Virtual environment: conda

Metadata

Metadata

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