jupyter_client
jupyter_client copied to clipboard
Kernel Restarter not being polled
I notice a behavior in Jupyter Server, where if I restart a kernel, the execution state is never set to restarting, because the restart callback is never invoked form Jupyter Client.
I believe the issue is that Jupyter Client never exposes, or calls, the poll method on the KernelRestarter which is responsible for calling the callbacks registered by the add_restart_callback methods on the KernelManager.
Should the KernelManager call the poll() method on its private property at some point? Or expose it to be called externally?
Hi @saulshanabrook.
The KernelRestarter exists solely for the purpose of detecting a kernel's unexpected termination at which time it will be automatically restarted. This is when the on-restart callbacks get called, etc. The poll() method is what is called periodically (every 3 seconds by default) to determine if the kernel is still active. As a result, if you kill the python kernel process, you should see the server console (log) issue a restart request within 3 seconds. The periodic callback is setup during the startup of the IOLoopKernelManager immediately following the kernel's startup.
Manually restarting a kernel doesn't go through this logic, but instead follows the restart_kernel() method on the configured KernelManager.
Thank you, Kevin, for the explanation!