interactive icon indicating copy to clipboard operation
interactive copied to clipboard

Dangling kernel process from connect command

Open duyang76 opened this issue 2 months ago • 9 comments

The package and version I'm asking about

Version: 1.0.6323010 OS: Windows

Question

I'm trying to create an out-of-process csharp kernel and use it side by side with the default (in-process) csharp kernel. The purpose is to show the results from two sets of binaries in one notebook.

I was able to start the process using either StdIoKernelConnector class or "#!connect studio" magic command. But I was not able to figure out 1) how to send the read/write from cells to connector, and 2) how to gracefully kill the new process when restarting the notebook.

It would be great if someone can provide some guidance.

Thank you

Update

The #!connect studio magic command creates a new kernel in a new process as expected. However, the new process doesn't go away when the notebook is restarted.

duyang76 avatar Oct 16 '25 19:10 duyang76

Can you post the complete command #!connect command you're running as well as screen shots of the full VS Code window afterwards?

What should happen is that a new kernel option (for whatever name you gave the connection) should appear in the cell kernel selector after the command has been run. Choosing that will send the command to the out-of-process kernel.

jonsequitur avatar Oct 16 '25 20:10 jonsequitur

Thank you for quick response.

I am writing from my phone because I cannot post from my company's computer. Please excuse any typos.

The command is #!connect stdio --kernel-name rootProxy --command ["\u0022<dotnet_path>\u0022", "<app_dll_path>", "stdio", "--default-kernel", "csharp"] , where <dotnet_path> and <app_dll_path> are both string literals, not variables.

Here is the screenshot. The kernel is added and available as the magic command of the next cell. The output confirms that it's in a new process. However, the new process doesn't go away when I restart the notebook.

Image

duyang76 avatar Oct 16 '25 20:10 duyang76

When I click the "select cell kernel" on the lower right corner of a new cell, the existing kernel (rootProxy) is not in the list. If I click "connect to new cell kernel", rootProxy shows up. But selecting it will not use the existing kernel. Instead a new cell is created and populated with the #! connect command.

@jonsequitur any thought? Thanks.

duyang76 avatar Oct 17 '25 14:10 duyang76

Connect to new cell kernel will generate a cell to connect to an external kernel. It's a most recently-used list. If the kernel was restarted you'll still have to run the #!connect command to get the kernel connected.

jonsequitur avatar Oct 17 '25 15:10 jonsequitur

This behavior works fine for me.

It goes back to my original question: when I restart the notebook, how can I gracefully kill the process created by the #! connect command?

duyang76 avatar Oct 17 '25 15:10 duyang76

Ah ok. It might be helpful to separate this into two different issues, one for the dangling process and the other for the connected kernel not appearing in the kernel cell chooser.

jonsequitur avatar Oct 17 '25 15:10 jonsequitur

Got it.

The dangling process is far more important to me. Is there an existing issue for this? If not, I will create one.

The kernel chooser issue is very minor, I won't even complain :)

duyang76 avatar Oct 17 '25 15:10 duyang76

I thought we might have an existing issue for the dangling process but I couldn't find it. We can just repurpose this one and I'll close as a duplicate if another issue turns up.

jonsequitur avatar Oct 17 '25 16:10 jonsequitur

Thank you. I will change the title and update the original post.

duyang76 avatar Oct 17 '25 16:10 duyang76