Reconnect to kernel on restart action #9371
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request addresses the issue raised in #8103 and closed by #8432. That change was not sufficient as the
reconnect()
was embedded within the_handleRestart()
method - which is conditionally called as a result of execution states ofautorestarting
orrestarting
, only the latter of which is returned by the server and only when the kernel is automatically restarted. No execution status is returned from the server upon completion of a manual restart request. As a result, the fixed code will never be reached upon a manual restart.Please note that relative to the originating issue, neither JupyterHub nor (arguably) Enterprise Gateway are related. The issue is really about whether a kernel's ZMQ ports are refreshed on manual restarts. For local kernels, that is atypical. For remote kernels deployed across managed clusters, it is the norm since the kernel's physical location is likely to change. EG happens to be a way kernels are deployed across a cluster.
This issue does not occur when using the Notebook UI - whose kernel restart behavior includes the reconnect sequence. As a result, this change brings parity with Notebook.
References
JupyterHub+JupyterLab+JupyterEnterpriseGateway Restart Kernel hangs #8013
Reconnect a websocket when a kernel is restarted. #8432
Code changes
We now explicitly call
reconnect()
immediately following the conclusion of the kernel restart request. This change was recommended by @blink1073 in #8013 (comment).User-facing changes
Restarts of kernels, irrespective of location, now yield a working (connected) kernel.
Backwards-incompatible changes
None - this change introduces parity with the Notebook UI wrt kernel restarts.