-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Improve kernel restart logic to reestablish ZMQ connection when a kernel is restarted with new ports #3284
Improve kernel restart logic to reestablish ZMQ connection when a kernel is restarted with new ports #3284
Conversation
…ate_stream and listen for the opened stream instead of calling open fnction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense; I've suggested a couple of simplifications. Based on my ideas for the corresponding jupyter_client PR, this will probably need an extra change in (I guess) notebook.services.kernels.kernelmanager
to tell the restarter that we can handle new ports.
newports = kwargs['newports'] | ||
else: | ||
self.log.debug('newports parameter is not defined, setting default to False') | ||
newports = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be simplified:
def on_kernel_restarted(self, newports=False):
...
# Connect to the stream with new ports | ||
try: | ||
self.create_stream() | ||
except web.HTTPError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see this is copied from the open()
method, but I don't think create_stream
can actually raise HTTPError
. Maybe it could at some point in the past. @minrk any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right. My guess is there used to be code in there where we were retrieving the kernel, which could raise 404, etc. Or it was just a mistake and this should have been Exception all along, which is what it should be now.
Closing this one as out of date, since a lot has changed in |
This proposal is based on jupyter/jupyter_client#348.
This proposal defines the logic for creating new ZMQ connection without closing existing websocket connection if a kernel was restarted with new ports (e.g. when the kernel is not responding during initial startup).
The following changes were added to the
on_kernel_restarted
function:kwargs
supportnewports
parameter fromkwargs
used if it is defined. If the parameter is not inkwargs
set it toFalse
newports == True
then existing ZMQ connection to the kernel is closed and new stream with updated ports is opened.newports == False
then client is notified that the kernel was restartedThis proposal solves the issue described in Kernel is not restarted with new ports if the kernel dies after the polling is started jupyter_client#347