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

Keep "--existing" kernel alive on Ctrl-D exit #127

Merged
merged 1 commit into from
Aug 3, 2017

Conversation

yangle
Copy link
Contributor

@yangle yangle commented Aug 2, 2017

When exiting from jupyter-console --existing by pressing Ctrl-D, the expected behavior is that the existing kernel is left alive. See #48 for a discussion. (This might be related to #126, too.)

Currently, however, the kernel is shut down upon console exit. This commit fixes this.


Apparently, setting self.keepkernel = True affects only the Ctrl-D behavior. The exit command still has keep_kernel=False by default.

Before:

jupyter-console jupyter-console --existing
exit Shutting down kernel Shutting down kernel
exit(keep_kernel=True) owning kernel, cannot keep it alive keeping kernel alive
Pressing Ctrl-D Shutting down kernel Shutting down kernel

After:

jupyter-console jupyter-console --existing
exit Shutting down kernel Shutting down kernel
exit(keep_kernel=True) owning kernel, cannot keep it alive keeping kernel alive
Pressing Ctrl-D owning kernel, cannot keep it alive keeping kernel alive

@takluyver
Copy link
Member

Thanks! One note - if you press Ctrl-D when it does own the kernel, I would rather keep the 'shutting down kernel' message. I think that can easily be done by setting keepkernel to not self.own_kernel. That latter attribute is set by the application when it sets up the shell object.

@yangle
Copy link
Contributor Author

yangle commented Aug 3, 2017

Indeed, setting self.keepkernel = not self.own_kernel changes the Ctrl-D exit to "Shutting down kernel" when not owning the kernel.

The commit has been updated.

After:

jupyter-console jupyter-console --existing
exit Shutting down kernel Shutting down kernel
exit(keep_kernel=True) owning kernel, cannot keep it alive keeping kernel alive
Pressing Ctrl-D Shutting down kernel keeping kernel alive

@takluyver takluyver added this to the 5.2 milestone Aug 3, 2017
@takluyver takluyver merged commit 30628ca into jupyter:master Aug 3, 2017
@takluyver
Copy link
Member

Thanks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants