Skip to content
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

Closed

Conversation

skukhtichev
Copy link

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:

Copy link
Member

@takluyver takluyver left a 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
Copy link
Member

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:
Copy link
Member

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?

Copy link
Member

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.

@blink1073
Copy link
Contributor

Closing this one as out of date, since a lot has changed in juptyer_client since.

@blink1073 blink1073 closed this Jun 8, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants