|
19 | 19 | from jupyter_client.session import Session |
20 | 20 | from jupyter_client.multikernelmanager import MultiKernelManager |
21 | 21 | from traitlets import (Any, Bool, Dict, List, Unicode, TraitError, Integer, |
22 | | - Instance, default, validate |
| 22 | + Float, Instance, default, validate |
23 | 23 | ) |
24 | 24 |
|
25 | 25 | from notebook.utils import to_os_path, exists |
@@ -93,6 +93,22 @@ def _update_root_dir(self, proposal): |
93 | 93 | no frontends are connected. |
94 | 94 | """ |
95 | 95 | ) |
| 96 | + |
| 97 | + kernel_info_timeout = Float(60, config=True, |
| 98 | + help="""Timeout for giving up on a kernel (in seconds). |
| 99 | +
|
| 100 | + On starting and restarting kernels, we check whether the |
| 101 | + kernel is running and responsive by sending kernel_info_requests. |
| 102 | + This sets the timeout in seconds for how long the kernel can take |
| 103 | + before being presumed dead. |
| 104 | + This affects the MappingKernelManager (which handles kernel restarts) |
| 105 | + and the ZMQChannelsHandler (which handles the startup). |
| 106 | + """ |
| 107 | + ) |
| 108 | + |
| 109 | + kernel_info_timeout = Integer(30, config=True, |
| 110 | + help="""This changes the amount of time that we wait for the kernel_info_reply the kernel restart is requested.""" |
| 111 | + ) |
96 | 112 |
|
97 | 113 | _kernel_buffers = Any() |
98 | 114 | @default('_kernel_buffers') |
@@ -305,7 +321,7 @@ def on_restart_failed(): |
305 | 321 | kernel.session.send(channel, "kernel_info_request") |
306 | 322 | channel.on_recv(on_reply) |
307 | 323 | loop = IOLoop.current() |
308 | | - timeout = loop.add_timeout(loop.time() + 30, on_timeout) |
| 324 | + timeout = loop.add_timeout(loop.time() + self.kernel_info_timeout, on_timeout) |
309 | 325 | return future |
310 | 326 |
|
311 | 327 | def notify_connect(self, kernel_id): |
@@ -434,4 +450,3 @@ def cull_kernel_if_idle(self, kernel_id): |
434 | 450 | self.log.warning("Culling '%s' kernel '%s' (%s) with %d connections due to %s seconds of inactivity.", |
435 | 451 | kernel.execution_state, kernel.kernel_name, kernel_id, connections, idle_duration) |
436 | 452 | self.shutdown_kernel(kernel_id) |
437 | | - |
|
0 commit comments