File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 7
7
# Distributed under the terms of the Modified BSD License.
8
8
import json
9
9
import os
10
+ import signal
10
11
import sys
11
12
import time
12
13
@@ -325,6 +326,18 @@ def initialize(self, argv=None):
325
326
super (IPEngineApp , self ).initialize (argv )
326
327
self .init_engine ()
327
328
self .forward_logging ()
329
+ self .init_signal ()
330
+
331
+ def init_signal (self ):
332
+ signal .signal (signal .SIGINT , self ._signal_sigint )
333
+ signal .signal (signal .SIGTERM , self ._signal_stop )
334
+
335
+ def _signal_sigint (self , sig , frame ):
336
+ self .log .warning ("Ignoring SIGINT. Terminate with SIGTERM." )
337
+
338
+ def _signal_stop (self , sig , frame ):
339
+ self .log .critical (f"received signal { sig } , stopping" )
340
+ self .loop .add_callback_from_signal (self .loop .stop )
328
341
329
342
def start (self ):
330
343
self .engine .start ()
You can’t perform that action at this time.
0 commit comments