Skip to content

Commit eef3718

Browse files
committed
avoid terminating engines with SIGINT
use SIGTERM
1 parent c307d5d commit eef3718

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ipyparallel/apps/ipengineapp.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# Distributed under the terms of the Modified BSD License.
88
import json
99
import os
10+
import signal
1011
import sys
1112
import time
1213

@@ -325,6 +326,18 @@ def initialize(self, argv=None):
325326
super(IPEngineApp, self).initialize(argv)
326327
self.init_engine()
327328
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)
328341

329342
def start(self):
330343
self.engine.start()

0 commit comments

Comments
 (0)