Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restarting Jupyter kernel is stuck and never finishes #16328

Open
1 of 2 tasks
marhoy opened this issue Dec 20, 2024 · 5 comments
Open
1 of 2 tasks

Restarting Jupyter kernel is stuck and never finishes #16328

marhoy opened this issue Dec 20, 2024 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel)

Comments

@marhoy
Copy link

marhoy commented Dec 20, 2024

Applies To

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

What happened?

Not sure if it related, but dependencies in my project is manager by uv. I have installed ipykernel (8.30.0) as a dev-dependency in the project which uses Python-3.12.8. In the Notebook, I have selected the .venv-kernel as my kernel.

When I start using the Notebook, everything works fine. But after running / restarting it a couple of times, it gets stuck on restarting the kernel. The notification window shows:

Image

And in the Jupyter Output, the last thing to be shown is:

11:00:30.125 [info] Restart requested ~/Projects/olt-chatbot/Testing3.ipynb
11:00:30.146 [info] Process Execution: ~/Projects/olt-chatbot/.venv/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"

The problem doesn't occur if I just open the Notebook and then reload it a lot of times. It typically happens after having worked with the Notebook for some minutes, running some code and restarting the Notebooks a couple of times.

I'm sorry I'm not able to describe the problem any better, will continue to investigate reasons...

VS Code Version

Version: 1.96.2 (user setup) Commit: fabdb6a30b49f79a7aba0f2ad9df9b399473380f Date: 2024-12-19T10:22:47.216Z Electron: 32.2.6 ElectronBuildId: 10629634 Chromium: 128.0.6613.186 Node.js: 20.18.1 V8: 12.8.374.38-electron.0 OS: Windows_NT x64 10.0.22631

Jupyter Extension Version

2024.11.0

Jupyter logs

Coding Language and Runtime Version

Python v3.12.8

Language Extension Version (if applicable)

Python extension 2024.22.0

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

N/A or Not sure

@marhoy marhoy added the bug Issue identified by VS Code Team member as probable bug label Dec 20, 2024
@DonJayamanne
Copy link
Contributor

Please could you enable logging as follows:

  • Open settings & go into Jupyter->Logging
  • Change the value to trace
  • Reload VS Code,
  • Attempt to repro the issue & then copy the output from the Jupyter output panel (use the command Jupyter: Show Output to get to the logs).

@DonJayamanne DonJayamanne added info-needed Issue requires more information from poster notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel) labels Dec 20, 2024
@marhoy
Copy link
Author

marhoy commented Dec 20, 2024

Thanks for the follow-up!
This time, it got stuck with a slightly different info message:

Image

The last things to be shown in the Jupyter output was (only the last 7 messages at the time of getting stuck):

22:49:36.298 [debug] Requesting Kernel info
22:49:36.299 [trace] Got Kernel info
22:49:36.299 [trace] End running kernel initialization, now waiting for idle
22:49:36.299 [trace] Waiting for idle on (kernel): 57a039ee-ec21-483e-ae14-142cd2b38ddb -> idle
22:49:36.299 [trace] Finished waiting for idle on (kernel): 57a039ee-ec21-483e-ae14-142cd2b38ddb -> idle
22:49:36.299 [trace] End running kernel initialization, session is idle
22:49:36.299 [trace] Registering commtarget jupyter.widget
22:52:25.176 [debug] creating new code watcher with matching document file:///home/~/Projects/olt-chatbot/src/olt_chatbot/chainlit_app.py
22:59:08.619 [debug] Restart kernel command handler for ~/Projects/olt-chatbot/Testing3.ipynb
22:59:08.619 [debug] restart the kernel, options.disableUI=false for ~/Projects/olt-chatbot/Testing3.ipynb
22:59:08.619 [info] Restart requested ~/Projects/olt-chatbot/Testing3.ipynb
22:59:08.620 [debug] Cancel pending cells
22:59:08.621 [debug] Dispose Kernel process 1616956.
22:59:08.640 [debug] Get Custom Env Variables, Class name = Pm, completed in 1ms, has a truthy return value, Arg 1: "~/Projects/olt-chatbot/Testing3.ipynb", Arg 2: "RunPythonCode"
22:59:08.675 [debug] KernelProcess Exited 1616956, Exit Code - undefined 

@DonJayamanne
Copy link
Contributor

Pleaser can you share the complete logs

@marhoy
Copy link
Author

marhoy commented Dec 22, 2024

I just experienced the same issue. This time on a Mac, in a different virtual environment.
Not sure if there is a link, but this enviroment is also managed by uv.

Full Jupyter trace log attached, but there's a lot of normal activity going on before it got stuck on restarting the kernel.
Maybe line 11360 is interesting?

jupyter.log

@DonJayamanne
Copy link
Contributor

Based on the logs it seems you may been using vscode for a while, hence the very large log

Also can you disable all other extensions when trying to replicate this issues, except for jupyter and python extensions. (Only to help isolate the issue and rule out other factors)

Please can you try to limit the activity and then share the logs
Basically I'd like to avoid other factors, when you use it for a while it's possible other factors play a role and is not easy to determine what they are

Also does this issues not repro in a non UV environment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel)
Projects
None yet
Development

No branches or pull requests

2 participants