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

Don't start kernel daemon for non-python kernels. #9298

Closed
claudiaregio opened this issue Mar 8, 2022 · 9 comments · Fixed by #9353
Closed

Don't start kernel daemon for non-python kernels. #9298

claudiaregio opened this issue Mar 8, 2022 · 9 comments · Fixed by #9353
Assignees
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel) verified Verification succeeded
Milestone

Comments

@claudiaregio
Copy link
Contributor

Request is to hide the "Jupyter: Debug Cell" command for .NET Nb.

Just had a user try to use it while using C# in a notebook and it completely broke their setup :(

We want to make sure users don't think they can use this debugging feature to the point where they are completely broken.

@claudiaregio claudiaregio added the bug Issue identified by VS Code Team member as probable bug label Mar 8, 2022
@rchiodo
Copy link
Contributor

rchiodo commented Mar 8, 2022

I think the user in your scenario was actually using a .NET kernel from Jupyter (not .NET interactive). We should make sure to disable debug cell for non python kernels.

@rchiodo rchiodo removed their assignment Mar 8, 2022
@rchiodo
Copy link
Contributor

rchiodo commented Mar 8, 2022

The command on the dropdown is already hidden:

            "notebook/cell/execute": [
                {
                    "command": "jupyter.runAndDebugCell",
                    "when": "notebookType == jupyter-notebook && jupyter.ispythonnotebook && notebookCellType == code && isWorkspaceTrusted && !jupyter.notebookeditor.runByLineInProgress"
                }
            ],

@rchiodo
Copy link
Contributor

rchiodo commented Mar 8, 2022

The command itself isn't flagged with a when clause though:

            {
                "command": "jupyter.runAndDebugCell",
                "title": "%jupyter.command.jupyter.debugCell.title%",
                "icon": "$(debug-alt-small)",
                "category": "Jupyter"
            },

@mrsharm
Copy link

mrsharm commented Mar 9, 2022

Just experienced an issue where my workflow was affected right after choosing "Jupyter: Debug Cell".

Whenever I tried to open a notebook, I got the following error:

Error: The kernel died. View Jupyter [log]() for further details. Error: Unhandled exception: System.IO.IOException: The process cannot access the file 'C:\Users\<UserName>\AppData\Local\Temp\tmp-4836JTB1GoV0BpKh.json' because it is being used by another process.

Things I tried

  • Deleting the file manually -- doesn't work since the Code.exe process still is holding on to it.
  • Closing VSCode and reopening -- doesn't fix it .. just creates a different tmp file in C:\Users<UserName>\AppData\Local\Temp
  • Closing the notebook and reopening leads to the same error.

To debug, I first looked up which process was holding the tmp file using ProcessExp and figured out it was a python process whose parent was a VS Code instance with the following command line args: "C:\Users<UserName>\AppData\Local\Programs\Microsoft VS Code\Code.exe" --ms-enable-electron-run-as-node --inspect-port=0 "c:\Users<UserName>\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-fork" --type=extensionHost --skipWorkspaceStorageLock

image

This gave me a hint that it must have been the Jupyter extension. And so I uninstalled the .NET Interactive VS Code Extension, uninstalled the Jupyter extension and then reinstall both and that fixed it.

A symptom of the issue was that I could put breakpoints in my notebook cells:

The full call stack is:

jupyter error.txt

@rchiodo
Copy link
Contributor

rchiodo commented Mar 10, 2022

@mrsharm What's the command line for the python process that was started?

In your scenario only .NET should be started to create/launch a kernel. So I'm curious why there's a python process involved at all.

@rchiodo rchiodo added info-needed Issue requires more information from poster and removed needs-triage labels Mar 10, 2022
@rchiodo rchiodo self-assigned this Mar 10, 2022
@mrsharm
Copy link

mrsharm commented Mar 11, 2022

I think I am able to repro this issue. Whenever the kernel is changed to .NET (C#) dotnet from .NET Interactive, I am unable to execute the cells of the notebook and the aforementioned issue shows up:

image

The python command line args are:

C:\Users\<Username>\AppData\Local\Microsoft\WindowsApps\python3.7.exe -m vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_interrupt_daemon -v --ppid 1508

I am convinced that choosing the "Jupyter: Debug Cell" automatically changed the Kernel to .NET C# and at this point, all the badness began.

The fix was to simply change the selected kernel and update all the cells to now point to the ".NET Interactive" flavor of C#.

@rchiodo
Copy link
Contributor

rchiodo commented Mar 11, 2022

We may be starting the interrupt daemon for non python kernels. That would be bad. I'll have to double check that. That's the python process you show in your command line args. Although not sure how it would have the file open? Maybe it's through file handle inheritance from the old kernel.

@rchiodo rchiodo added needs-triage and removed info-needed Issue requires more information from poster labels Mar 11, 2022
@rchiodo rchiodo removed their assignment Mar 11, 2022
@greazer greazer changed the title Hide Jupyter debug command for .NET nb Hide Jupyter debug cell command for .NET nb Mar 14, 2022
@greazer greazer added notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel) and removed needs-triage labels Mar 14, 2022
@greazer greazer added this to the March 2022 milestone Mar 14, 2022
@greazer greazer changed the title Hide Jupyter debug cell command for .NET nb Don't start kernel daemon for non-python kernels. Mar 14, 2022
@DonJayamanne DonJayamanne self-assigned this Mar 14, 2022
@rchiodo
Copy link
Contributor

rchiodo commented Mar 25, 2022

@mrsharm can you verify we've fixed your problem?

To verify:

  • Install VS code insiders
  • Install the latest 'prerelease' jupyter extension
  • Repro the steps you had before

Verify your kernel doesn't immediately die.

Thanks.

@rchiodo rchiodo added the author-verification-requested Issues potentially verifiable by issue author label Mar 25, 2022
@mrsharm
Copy link

mrsharm commented Mar 28, 2022

@rchiodo, just tried this out and seems like the "Jupyter: Debug Cell" option is still there, however, it doesn't break my workflow i.e. no issue with executing the cells after the selection.

Thanks for the help!

@rchiodo rchiodo added the verified Verification succeeded label Mar 28, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel) verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants