##// END OF EJS Templates
change how failed restarts are detected...
MinRK -
Show More
@@ -19,7 +19,7 b' It is an incomplete base class, and must be subclassed.'
19
19
20 from IPython.config.configurable import LoggingConfigurable
20 from IPython.config.configurable import LoggingConfigurable
21 from IPython.utils.traitlets import (
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 help="""Kernel heartbeat interval in seconds."""
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 _restarting = Bool(False)
41 _restarting = Bool(False)
42 _restart_count = Integer(0)
39
43
40 callbacks = Dict()
44 callbacks = Dict()
41 def _callbacks_default(self):
45 def _callbacks_default(self):
@@ -86,12 +90,21 b' class KernelRestarter(LoggingConfigurable):'
86 self.log.debug('Polling kernel...')
90 self.log.debug('Polling kernel...')
87 if not self.kernel_manager.is_alive():
91 if not self.kernel_manager.is_alive():
88 if self._restarting:
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 self.log.warn("KernelRestarter: restart failed")
98 self.log.warn("KernelRestarter: restart failed")
90 self._fire_callbacks('dead')
99 self._fire_callbacks('dead')
91 self._restarting = False
100 self._restarting = False
101 self._restart_count = 0
92 self.stop()
102 self.stop()
93 else:
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 self._fire_callbacks('restart')
108 self._fire_callbacks('restart')
96 self.kernel_manager.restart_kernel(now=True)
109 self.kernel_manager.restart_kernel(now=True)
97 self._restarting = True
110 self._restarting = True
General Comments 0
You need to be logged in to leave comments. Login now