vscode-jupyter: Notebook cell gets stuck in 'Pending' state

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

When I start a notebook with ‘Run all’ and I have to kill the kernel for some reason with the kill command from the terminal the notebook cells that haven’t been executed can get stuck in the ‘Pending’ state (little clock icon). Even if I close the notebook and reopen it, I cannot execute these pending cells anymore unless I convert them to a markdown cell and back. It would be great if the pending flag was reset when the kernel dies or otherwise killed without using the vscode ‘Interrupt’ and ‘Restart’ buttons. I have to restart vscode for the ‘Pending’ flags to go away. This is a vscode issue, the underlying kernel runs just fine.

No entry in the Jupyter log when I try to execute a cell marked as pending, so apparently vscode doesn’t even attempt to execute that cell.

VS Code Version

Version: 1.77.3 (system setup) Commit: 704ed70d4fd1c6bd6342c436f1ede30d1cff4710 Date: 2023-04-12T09:16:02.548Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Windows_NT x64 10.0.19045 Sandboxed: No

Jupyter Extension Version

v2023.3.1201040234

Jupyter logs

--

Coding Language and Runtime Version

No response

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Remote

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 8
  • Comments: 58 (23 by maintainers)

Most upvoted comments

I am also having the exact same problem.

Me too!

Facing the very same issue. I have to reload VSC to make it work. After some time, it’s starts showing “Pending” status to cell again. It’s so frustrating specially when you’re working with huge data. After loading the data, at some point, it starts doing again and I have to reload the VSC again. Not only that, sometimes its IntelliSense stops working too

This happens for me when debugging cells:

  1. Debug a cell
  2. Disconnect from debugger
  3. Try stopping cell or letting it run its course
  4. Stop button remains and execution never seems to end
  5. Realize that other cells can run fine - this cell’s just stuck waiting for some sort of conclusionary signal or something.
  6. Interrupting (toolbar or cell execution button) does nothing

Had the same issue here, ended up realizing that the problem came from Pylance: https://github.com/microsoft/pylance-release/issues/5019

To solve it downgrade the Pylance of Vscode to 2023.10.4 Seems to work for now.

Same problem with the execution of n cell with local jupyter kernel after today’s upgrade to

Version: 1.79.2 (system setup) Commit: 695af097c7bd098fbf017ce3ac85e09bbc5dda06 Date: 2023-06-14T08:57:04.379Z Electron: 22.5.7 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Windows_NT x64 10.0.19045

ipykernel == 6.21.2 Python == 3.9.7

In terminal ipython the same code works fine.

The execution of every next cell get stuck with long Pending cell status (min. 10 seconds for eg. declare an empty list) always after run a cell that contains the following code:

def split_list_to_n_elements_lists(list_to_split: list, elements_in_one_chunk: int) -> list[list]:
    return [list_to_split[x : x + elements_in_one_chunk] for x in range(0, len(list_to_split), elements_in_one_chunk)]

chunked_list_of_strings = split_list_to_n_elements_lists(list_of_strings, 30)

image

Did downgrading or disabling the Pylance extension work?

If you have Ruff or similar python extensions, please consider disabling those as well. Basically disable all except

  • Python
  • Jupyter
  • Notebook Renderers

As I suspect this issue is caused by some other extension.

No, I only have extensions Python, Jupyter, GitHub Copliot, Pylance. Now, I think Pylance maybe is the reason.

@CNwangbin Did downgrading or disabling the Pylance extension work?

I am trying to do this. Report you later.

@CNwangbin Thank you very much for the logs, very useful While executing cells from ‘. temp_view_mdeep_data.ipynb’ Did you at any point

  • delete any cells
  • Or close this notebook

Did you happen to disable all extensions?

based on the logs cells were deleted and the notebook was closed

No, I didn’t do any operation of them. I think it may caused by pylance. I will try to disable pylance extention and continue my work. If that is true or not true, I will report at there soon.

Same problem

No, I just debug my code in a cell. For example, I run some cells, and I revised my code in the last cell.

Are you using the debug functionality? or when you say debug you mean thats your workflow and not using Python Debugger in notebook is that right.

The debug I said is just I am revising my code in the jupyter cell.

Still having this issue. Can’t run a single notebook cell. Even when I quit VSCode and restart.

me too… still i don’t know why