File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,10 @@ class KernelRestarter(LoggingConfigurable):
34
34
restart_limit = Integer (5 , config = True ,
35
35
help = """The number of consecutive autorestarts before the kernel is presumed dead."""
36
36
)
37
+
38
+ random_ports_until_alive = Bool (False , config = True ,
39
+ help = """Whether to choose new random ports when restarting before the kernel is alive."""
40
+ )
37
41
_restarting = Bool (False )
38
42
_restart_count = Integer (0 )
39
43
_initial_startup = Bool (True )
@@ -99,13 +103,14 @@ def poll(self):
99
103
self ._restart_count = 0
100
104
self .stop ()
101
105
else :
106
+ newports = self .random_ports_until_alive and self ._initial_startup
102
107
self .log .info ('KernelRestarter: restarting kernel (%i/%i), %s random ports' ,
103
108
self ._restart_count ,
104
109
self .restart_limit ,
105
- 'new' if self . _initial_startup else 'keep'
110
+ 'new' if newports else 'keep'
106
111
)
107
112
self ._fire_callbacks ('restart' )
108
- self .kernel_manager .restart_kernel (now = True , newports = self . _initial_startup )
113
+ self .kernel_manager .restart_kernel (now = True , newports = newports )
109
114
self ._restarting = True
110
115
else :
111
116
if self ._initial_startup :
You can’t perform that action at this time.
0 commit comments