##// END OF EJS Templates
exiting processes properly
José Chávez -
r924:8925c3feabcd
parent child
Show More
@@ -32,6 +32,9 def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, recei
32 nFiles = None
32 nFiles = None
33 processes = []
33 processes = []
34
34
35
36
37
35 dt1 = datetime.datetime.strptime(startDate, '%Y/%m/%d')
38 dt1 = datetime.datetime.strptime(startDate, '%Y/%m/%d')
36 dt2 = datetime.datetime.strptime(endDate, '%Y/%m/%d')
39 dt2 = datetime.datetime.strptime(endDate, '%Y/%m/%d')
37 days = (dt2 - dt1).days
40 days = (dt2 - dt1).days
@@ -47,29 +50,24 def multiSchain(child, nProcess=cpu_count(), startDate=None, endDate=None, recei
47 nFiles = q.get()
50 nFiles = q.get()
48 firstProcess.terminate()
51 firstProcess.terminate()
49 skip = int(math.ceil(nFiles/nProcess))
52 skip = int(math.ceil(nFiles/nProcess))
50 try:
51 while True:
53 while True:
52 processes.append(Process(target=child, args=(cursor, skip, q, dt)))
54 processes.append(Process(target=child, args=(cursor, skip, q, dt)))
53 processes[cursor].start()
55 processes[cursor].start()
54 if nFiles < cursor*skip:
56 if nFiles < cursor*skip:
55 break
57 break
56 cursor += 1
58 cursor += 1
57 except KeyboardInterrupt:
59
60 def beforeExit(exctype, value, trace):
58 for process in processes:
61 for process in processes:
59 process.terminate()
62 process.terminate()
60 process.join()
63 process.join()
61 for process in processes:
64 sys.excepthook = beforeExit
62 process.join()
63 # process.terminate()
64 sleep(3)
65
65
66 try:
67 while True:
68 pass
69 except KeyboardInterrupt:
70 for process in processes:
66 for process in processes:
71 process.terminate()
72 process.join()
67 process.join()
68 process.terminate()
69
70
73
71
74 class ParameterConf():
72 class ParameterConf():
75
73
@@ -1,1 +1,1
1 <Project description="Segundo Test" id="191" name="test01"><ProcUnit datatype="ReceiverData" id="1911" inputId="0" name="ReceiverData"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="bool" id="191111" name="realtime" value="1" /><Parameter format="str" id="191112" name="plottypes" value="rti" /><Parameter format="str" id="191113" name="plot_server" value="tcp://10.10.10.82:7000" /></Operation></ProcUnit></Project> No newline at end of file
1 <Project description="HF_EXAMPLE" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/home/nanosat/data/hysell_data20/pdata" /><Parameter format="date" id="191113" name="startDate" value="2015/09/26" /><Parameter format="date" id="191114" name="endDate" value="2015/09/26" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="cursor" value="33" /><Parameter format="int" id="191119" name="skip" value="22" /><Parameter format="int" id="191120" name="delay" value="10" /><Parameter format="int" id="191121" name="walk" value="1" /><Parameter format="int" id="191122" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="PublishData" priority="2" type="other"><Parameter format="int" id="191221" name="zeromq" value="1" /><Parameter format="int" id="191222" name="delay" value="1" /></Operation></ProcUnit></Project> No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now