Merge pull request #3665 from mpacer/reply_timeout

add kernel_info_timeout traitlet for slow kernel start/restart
This commit is contained in:
Min RK 2018-06-08 15:50:55 +02:00 committed by GitHub
commit 2c061a45ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -104,7 +104,8 @@ class ZMQChannelsHandler(AuthenticatedZMQStreamHandler):
@property @property
def kernel_info_timeout(self): def kernel_info_timeout(self):
return self.settings.get('kernel_info_timeout', 10) km_default = self.kernel_manager.kernel_info_timeout
return self.settings.get('kernel_info_timeout', km_default)
@property @property
def iopub_msg_rate_limit(self): def iopub_msg_rate_limit(self):

View File

@ -19,7 +19,7 @@ from tornado.ioloop import IOLoop, PeriodicCallback
from jupyter_client.session import Session from jupyter_client.session import Session
from jupyter_client.multikernelmanager import MultiKernelManager from jupyter_client.multikernelmanager import MultiKernelManager
from traitlets import (Any, Bool, Dict, List, Unicode, TraitError, Integer, from traitlets import (Any, Bool, Dict, List, Unicode, TraitError, Integer,
Instance, default, validate Float, Instance, default, validate
) )
from notebook.utils import to_os_path, exists from notebook.utils import to_os_path, exists
@ -93,6 +93,18 @@ class MappingKernelManager(MultiKernelManager):
no frontends are connected. no frontends are connected.
""" """
) )
kernel_info_timeout = Float(60, config=True,
help="""Timeout for giving up on a kernel (in seconds).
On starting and restarting kernels, we check whether the
kernel is running and responsive by sending kernel_info_requests.
This sets the timeout in seconds for how long the kernel can take
before being presumed dead.
This affects the MappingKernelManager (which handles kernel restarts)
and the ZMQChannelsHandler (which handles the startup).
"""
)
_kernel_buffers = Any() _kernel_buffers = Any()
@default('_kernel_buffers') @default('_kernel_buffers')
@ -305,7 +317,7 @@ class MappingKernelManager(MultiKernelManager):
kernel.session.send(channel, "kernel_info_request") kernel.session.send(channel, "kernel_info_request")
channel.on_recv(on_reply) channel.on_recv(on_reply)
loop = IOLoop.current() loop = IOLoop.current()
timeout = loop.add_timeout(loop.time() + 30, on_timeout) timeout = loop.add_timeout(loop.time() + self.kernel_info_timeout, on_timeout)
return future return future
def notify_connect(self, kernel_id): def notify_connect(self, kernel_id):
@ -434,4 +446,3 @@ class MappingKernelManager(MultiKernelManager):
self.log.warning("Culling '%s' kernel '%s' (%s) with %d connections due to %s seconds of inactivity.", self.log.warning("Culling '%s' kernel '%s' (%s) with %d connections due to %s seconds of inactivity.",
kernel.execution_state, kernel.kernel_name, kernel_id, connections, idle_duration) kernel.execution_state, kernel.kernel_name, kernel_id, connections, idle_duration)
self.shutdown_kernel(kernel_id) self.shutdown_kernel(kernel_id)