Show More
@@ -19,7 +19,7 b' It is an incomplete base class, and must be subclassed.' | |||
|
19 | 19 | |
|
20 | 20 | from IPython.config.configurable import LoggingConfigurable |
|
21 | 21 | from IPython.utils.traitlets import ( |
|
22 | Instance, Float, Dict, Bool, | |
|
22 | Instance, Float, Dict, Bool, Integer, | |
|
23 | 23 | ) |
|
24 | 24 | |
|
25 | 25 | #----------------------------------------------------------------------------- |
@@ -35,7 +35,11 b' class KernelRestarter(LoggingConfigurable):' | |||
|
35 | 35 | help="""Kernel heartbeat interval in seconds.""" |
|
36 | 36 | ) |
|
37 | 37 | |
|
38 | restart_limit = Integer(5, config=True, | |
|
39 | help="""The number of consecutive autorestarts before the kernel is presumed dead.""" | |
|
40 | ) | |
|
38 | 41 | _restarting = Bool(False) |
|
42 | _restart_count = Integer(0) | |
|
39 | 43 | |
|
40 | 44 | callbacks = Dict() |
|
41 | 45 | def _callbacks_default(self): |
@@ -86,12 +90,21 b' class KernelRestarter(LoggingConfigurable):' | |||
|
86 | 90 | self.log.debug('Polling kernel...') |
|
87 | 91 | if not self.kernel_manager.is_alive(): |
|
88 | 92 | if self._restarting: |
|
93 | self._restart_count += 1 | |
|
94 | else: | |
|
95 | self._restart_count = 1 | |
|
96 | ||
|
97 | if self._restart_count >= self.restart_limit: | |
|
89 | 98 | self.log.warn("KernelRestarter: restart failed") |
|
90 | 99 | self._fire_callbacks('dead') |
|
91 | 100 | self._restarting = False |
|
101 | self._restart_count = 0 | |
|
92 | 102 | self.stop() |
|
93 | 103 | else: |
|
94 |
self.log.info('KernelRestarter: restarting kernel' |
|
|
104 | self.log.info('KernelRestarter: restarting kernel (%i/%i)', | |
|
105 | self._restart_count, | |
|
106 | self.restart_limit | |
|
107 | ) | |
|
95 | 108 | self._fire_callbacks('restart') |
|
96 | 109 | self.kernel_manager.restart_kernel(now=True) |
|
97 | 110 | self._restarting = True |
General Comments 0
You need to be logged in to leave comments.
Login now