-
Notifications
You must be signed in to change notification settings - Fork 287
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
jupyter kernel
process doesn't exit after kernel is shutdown
#941
Comments
I'm not sure what the original intention was for It only terminates upon reception of the either If you're worried about ZMQ ports getting leaked, the actual kernel process is shut down. Only its launching application (i.e., ((Frankly, I don't know what purpose |
Hmm I see. That's what I ended up settled on, storing a .pid file alongside the .json connection file, and killing the process later when done with it (although with that I didn't bother doing a km.shutdown() which probably isn't graceful). The way I'm using jupyter kernel is to manage a persistent python kernel in my terminal of choice, send commands or stdin to it from my terminal prompt, and print the stdout/stderr back into the terminal. https://github.com/digitalsignalperson/comma-python/blob/main/%2Cpython If this is an ok place to ask, I also ran into sometimes after creating a new kernel, calling km.execute(to_execute) immediately never results in a km.iopub_channel.msg_ready() returing True. I'm not sure what the correct way to deal with that is, if there's some method to check and wait for before trying to execute something. Notes here: ,python#L70 |
If you "kill" the processs using
I believe the best way to ensure a kernel is ready to receive execution requests is to complete a |
thanks, I've switched to SIGTERM
If I remove my 1 second sleep before I try to execute something and add the kernel info request, it now similarly does not get the response from the kernel_info_request sometimes The code is doing more or less this: cf = jupyter_client.find_connection_file(connection_file_path)
km = jupyter_client.BlockingKernelClient(connection_file=cf)
km.load_connection_file()
km.kernel_info()
while True:
if km.iopub_channel.msg_ready():
# Sometimes msg_ready() never returns True, other times I do see the kernel_info_request e.g. sometimes this works
soometimes it doesn't
|
I see that your repo references |
The SUB socket of the client can take time to connect to the IOPUB channel, and the client can miss important messages (especially those with the kernel status). The current workaround implemented in different clients is to "nudge" the kernel, i.e. send requests until the SUB socket is connected and able to receive the "idle" status message (i.e. having The next version of the protocol will fix this issue "by design", using a socket that broadcasts a message when it receives a new connection. Clients can wait for this message on iopub (which is guaranteed to be delivered by ZMQ) before sending requests to the message. You can find the detail of this JEP here. The JEP has been accepted, but not implemented yet. |
If I do
and then e.g.
the original
jupyter kernel
process doesn't exit.Same thing if I shut it down like this
my setup on arch linux with:
The text was updated successfully, but these errors were encountered: