vscode-jupyter: Cannot restart kernel after kernel dies

Environment data

  • VS Code version: Version: 1.59.0 Commit: 379476f0e13988d90fab105c5c19e7abc8b1dea8 Date: 2021-08-04T23:14:40.191Z (1 wk ago) Electron: 13.1.7 Chrome: 91.0.4472.124 Node.js: 14.16.0 V8: 9.1.269.36-electron.0 OS: Darwin x64 20.6.0

  • Jupyter Extension version (available under the Extensions sidebar): v2021.8.1195043623

  • Python Extension version (available under the Extensions sidebar): v2021.8.1105858891

  • OS (Windows | Mac | Linux distro) and version: MacOS 11.5.1

  • Python and/or Anaconda version: Python 3.9.5 (also tested with 3.9.6, 3.8.10 and 3.7 - same issue)

  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): tested with conda and venv

  • Jupyter server running: The problem happens both locally and in a remote setup (remote VM)

Expected behaviour

I need to restart my kernel after a pip install. I need to execute the following code and restart my kernel, without loosing connectivity to it.

import IPython  
app = IPython.Application.instance()  
app.kernel.do_shutdown(True) 

Actual behaviour

After executing the app.kernel.do_shutdown(True) I receive the following message:

Error: Session cannot generate requests
Error: Session cannot generate requests
at w.executeCodeCell (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:325139)
at w.execute (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:324460)
at w.start (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:320276)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async t.CellExecutionQueue.executeQueuedCells (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:334803)
at async t.CellExecutionQueue.start (/Users/renatoleite/.vscode/extensions/ms-toolsai.jupyter-2021.8.1195043623/out/client/extension.js:90:334343)

If I restart the kernel using the “Restart” button from the UI interface, I still receive the same message. I can only get my environment running again if I select another kernel and then select the original kernel again.

Steps to reproduce:

  1. Create an empty notebook and open in VScode (with the extension enabled).
  2. Enable the kernel
  3. On the first cell type a print('Hello World') to make sure it is working
  4. On the second cell execute the following code:
import IPython  
app = IPython.Application.instance()  
app.kernel.do_shutdown(True) 
  1. Include a new cell with a print('Hello world') to see the error message.

Logs

Please see the attached files. kernel_restart_OK.txt cell_exec_FAIL.txt requirements.txt

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 17 (8 by maintainers)

Most upvoted comments

I have the same issue. If I run the code with Jupyter v2021.8.2041215044,when I run this demo(https://tensorflow.google.cn/text/tutorials/transformer?hl=zh_cn), Error: Session cannot generate requests will rise. So I use an old version Jupyter, and this issue will disappear

@momt99

Please could you file a separate issue. looks like you have some code in the cell that’s causing the kernel to crash/die.

That’s great! Thank you very much, Cheers