Skip to content

support async kernel shutdown #4425

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion notebook/services/kernels/kernelmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def stop_buffering(self, kernel_id):
self.log.info("Discarding %s buffered messages for %s",
len(msg_buffer), buffer_info['session_key'])

@gen.coroutine
def shutdown_kernel(self, kernel_id, now=False):
"""Shutdown a kernel by kernel_id"""
self._check_kernel_id(kernel_id)
Expand All @@ -300,7 +301,8 @@ def shutdown_kernel(self, kernel_id, now=False):
type=self._kernels[kernel_id].kernel_name
).dec()

return super(MappingKernelManager, self).shutdown_kernel(kernel_id, now=now)
ret = yield gen.maybe_future(super(MappingKernelManager, self).shutdown_kernel(kernel_id, now=now))
raise gen.Return(ret)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This already supported async shutdown_kernel without any change, so I don't think we should merge this. Since shutdown_kernel is not itself async, returning the super().shutdown_kernel() works if shutdown_kernel is async, since it will return a Future or coroutine object, which gets passed through to the caller of this method.


@gen.coroutine
def restart_kernel(self, kernel_id):
Expand Down