@@ -72,7 +72,6 @@ def initiate(self, **kwargs):
7272 self .start_time = time .time ()
7373 wait_interval = 1.0 / self .config ['tickrate' ] if self .config ['tickrate' ] >= 1 else 0
7474 last_save = 0
75- ab_code = 0
7675
7776 if not self .register : raise RuntimeError ('NodeRegister has not been initialized!' )
7877
@@ -120,7 +119,7 @@ def initiate(self, **kwargs):
120119 if p .id >= 0 and p not in self .register .completed_nodes .union (self .register .norun_nodes ):
121120 runnable = False
122121 break
123- if runnable :
122+ if runnable and node . is_runnable () :
124123 self .register .pending_nodes .remove (node )
125124 node .context = self .context
126125 node .execute ()
@@ -147,7 +146,6 @@ def initiate(self, **kwargs):
147146 print ('\n Keyboard Interrupt Received' )
148147 print ('\n Cancelling Execution' )
149148 self ._abort_all_workers ()
150- self .save_state_func (False , True )
151149 return - 1
152150
153151 # App lifecycle - SUCCESS
@@ -164,7 +162,7 @@ def initiate(self, **kwargs):
164162 self ._on_destroy_func ()
165163
166164 if not kwargs .get ('silent' ):
167- self ._print_final_state (ab_code )
165+ self ._print_final_state ()
168166
169167 if not self .config ['test_mode' ] and self .save_state_func :
170168 self .save_state_func ()
@@ -173,10 +171,12 @@ def initiate(self, **kwargs):
173171
174172 def _abort_all_workers (self ):
175173 for node in self .register .running_nodes .copy ():
176- node .terminate ()
174+ node .terminate ('Keyboard Interrupt (SIGINT) received. Terminating Worker and exiting.' )
177175 self .register .running_nodes .remove (node )
178176 self .register .aborted_nodes .add (node )
179177 self .register .set_children_defaulted (node )
178+ self .save_state_func (False , True )
179+ self ._print_final_state (True )
180180
181181 def _print_current_state (self ):
182182 elapsed = time .time () - self .start_time
@@ -205,39 +205,42 @@ def _print_current_state(self):
205205
206206 return
207207
208- def _print_final_state (self , ab_code = 0 ):
208+ def _print_final_state (self , aborted = False ):
209209 print ('\n Completed in {:0.2f} seconds\n ' .format (time .time () - self .start_time ))
210210
211- if ab_code > 0 :
211+ if aborted :
212212 print ('Final Status: ABORTED\n ' )
213+ print ('Aborted Processes:\n ' )
214+
215+ for n in self .register .aborted_nodes :
216+ self ._print_node_info (n , self .config ['dump_logs' ])
217+
213218 elif len (self .register .failed_nodes ) + len (self .register .defaulted_nodes ):
214219 print ('Final Status: FAILURE\n ' )
215220 print ('Failed Processes:\n ' )
216221
217222 for n in self .register .failed_nodes :
218- print ('ID: {}' .format (n .id ))
219- print ('Name: {}' .format (n .name ))
220- print ('Module: {}' .format (n .module ))
221- print ('Worker: {}' .format (n .worker ))
222- print ('Arguments: {}' .format (n .arguments ))
223- print ('Log File: {}\n ' .format (n .logfile ))
224-
225- if self .config ['dump_logs' ]:
226- print ('DUMPING FAILURE LOGS\n ' )
227-
228- for n in self .register .failed_nodes :
229- print ('############################################################################' )
230- print ('# ID: {}' .format (n .id ))
231- print ('# Name: {}' .format (n .name ))
232- print ('# Module: {}' .format (n .module ))
233- print ('# Worker: {}' .format (n .worker ))
234- print ('# Arguments: {}' .format (n .arguments ))
235- print ('# Log File: {}' .format (n .logfile ))
236- with open (n .logfile , 'r' ) as f :
237- for line in f :
238- print (line , end = '' )
223+ self ._print_node_info (n , self .config ['dump_logs' ])
239224
240225 else :
241226 print ('Final Status: SUCCESS\n ' )
242227
243- return
228+ return
229+
230+ def _print_node_info (self , n , dump_logs = False ):
231+ if dump_logs :
232+ print ('############################################################################' )
233+
234+ print ('# ID: {}' .format (n .id ))
235+ print ('# Name: {}' .format (n .name ))
236+ print ('# Module: {}' .format (n .module ))
237+ print ('# Worker: {}' .format (n .worker ))
238+ print ('# Arguments: {}' .format (n .arguments ))
239+ print ('# Log File: {}' .format (n .logfile ))
240+
241+ if dump_logs :
242+ with open (n .logfile , 'r' ) as f :
243+ for line in f :
244+ print (line , end = '' )
245+
246+ print ('' )
0 commit comments