##// END OF EJS Templates
Add handler to terminate child process
Juan C. Espinoza -
r1533:37c6d1c7452d
parent child
Show More
@@ -14,7 +14,8 import datetime
14 14 import traceback
15 15 import time
16 16 import multiprocessing
17 from multiprocessing import Process, Queue
17 import signal as sig
18 from multiprocessing import Process, Queue, active_children
18 19 from threading import Thread
19 20 from xml.etree.ElementTree import ElementTree, Element, SubElement
20 21
@@ -25,6 +26,15 from schainpy.utils import log
25 26 if 'darwin' in sys.platform and sys.version_info[0] == 3 and sys.version_info[1] > 7:
26 27 multiprocessing.set_start_method('fork')
27 28
29 def handler(sig, frame):
30 # get all active child processes
31 active = active_children()
32 # terminate all active children
33 for child in active:
34 child.terminate()
35 # terminate the process
36 sys.exit(0)
37
28 38 class ConfBase():
29 39
30 40 def __init__(self):
@@ -659,6 +669,7 class Project(Process):
659 669 self.started = True
660 670 self.start_time = time.time()
661 671 self.createObjects()
672 sig.signal(sig.SIGTERM, handler)
662 673 self.runProcs()
663 674 log.success('{} Done (Time: {:4.2f}s)'.format(
664 675 self.name,
General Comments 0
You need to be logged in to leave comments. Login now