Skip to content

Commit

Permalink
Merge pull request #4412 from kevin-bates/async-startup
Browse files Browse the repository at this point in the history
Enable restart_kernel for async usage
  • Loading branch information
minrk authored Feb 25, 2019
2 parents 46ee18b + 2c526fb commit bba82ca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions notebook/services/kernels/kernelmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,11 @@ def shutdown_kernel(self, kernel_id, now=False):

return super(MappingKernelManager, self).shutdown_kernel(kernel_id, now=now)

@gen.coroutine
def restart_kernel(self, kernel_id):
"""Restart a kernel by kernel_id"""
self._check_kernel_id(kernel_id)
super(MappingKernelManager, self).restart_kernel(kernel_id)
yield gen.maybe_future(super(MappingKernelManager, self).restart_kernel(kernel_id))
kernel = self.get_kernel(kernel_id)
# return a Future that will resolve when the kernel has successfully restarted
channel = kernel.connect_shell()
Expand Down Expand Up @@ -341,7 +342,7 @@ def on_restart_failed():
channel.on_recv(on_reply)
loop = IOLoop.current()
timeout = loop.add_timeout(loop.time() + self.kernel_info_timeout, on_timeout)
return future
raise gen.Return(future)

def notify_connect(self, kernel_id):
"""Notice a new connection to a kernel"""
Expand Down

0 comments on commit bba82ca

Please sign in to comment.