@@ -1058,7 +1058,7 @@ def run_flows(self):
1058
1058
if stdout_behaviour == subprocess .PIPE :
1059
1059
os .set_blocking (ps .stdout .fileno (), False )
1060
1060
1061
- self .__ps_to_kill .append ({'ps' : ps , 'cmd' : inner_el ['command' ], 'ps_group' : False })
1061
+ self .__ps_to_kill .append ({'ps' : ps , 'cmd' : inner_el ['command' ]})
1062
1062
else :
1063
1063
print (f"Process should be synchronous. Alloting { config ['measurement' ]['flow-process-runtime' ]} s runtime ..." )
1064
1064
ps = subprocess .run (
@@ -1103,7 +1103,11 @@ def stop_metric_providers(self):
1103
1103
if stderr_read is not None and str (stderr_read ):
1104
1104
errors .append (f"Stderr on { metric_provider .__class__ .__name__ } was NOT empty: { stderr_read } " )
1105
1105
1106
- metric_provider .stop_profiling ()
1106
+ # pylint: disable=broad-exception-caught
1107
+ try :
1108
+ metric_provider .stop_profiling ()
1109
+ except Exception as exc :
1110
+ errors .append (f"Could not stop profiling on { metric_provider .__class__ .__name__ } : { str (exc )} " )
1107
1111
1108
1112
df = metric_provider .read_metrics (self ._run_id , self .__containers )
1109
1113
if isinstance (df , int ):
@@ -1124,7 +1128,17 @@ def stop_metric_providers(self):
1124
1128
1125
1129
def read_and_cleanup_processes (self ):
1126
1130
print (TerminalColors .HEADER , '\n Reading process stdout/stderr (if selected) and cleaning them up' , TerminalColors .ENDC )
1127
- process_helpers .kill_ps (self .__ps_to_kill )
1131
+
1132
+ ps_errors = []
1133
+ for ps in self .__ps_to_kill :
1134
+ try :
1135
+ process_helpers .kill_ps (ps ['ps' ], ps ['cmd' ])
1136
+ except ProcessLookupError as exc : # Process might have done expected exit already. However all other errors shall bubble
1137
+ ps_errors .append (f"Could not kill { ps ['cmd' ]} . Exception: { exc } " )
1138
+ if ps_errors :
1139
+ raise RuntimeError (ps_errors )
1140
+ self .__ps_to_kill = [] # we need to clear, so we do not kill twice later
1141
+
1128
1142
for ps in self .__ps_to_read :
1129
1143
if ps ['detach' ]:
1130
1144
stdout , stderr = ps ['ps' ].communicate (timeout = 5 )
@@ -1240,7 +1254,12 @@ def cleanup(self):
1240
1254
1241
1255
print ('Stopping metric providers' )
1242
1256
for metric_provider in self .__metric_providers :
1243
- metric_provider .stop_profiling ()
1257
+ # pylint: disable=broad-exception-caught
1258
+ try :
1259
+ metric_provider .stop_profiling ()
1260
+ except Exception as exc :
1261
+ error_helpers .log_error (f"Could not stop profiling on { metric_provider .__class__ .__name__ } : { str (exc )} " )
1262
+
1244
1263
1245
1264
print ('Stopping containers' )
1246
1265
for container_id in self .__containers :
@@ -1257,7 +1276,16 @@ def cleanup(self):
1257
1276
1258
1277
self .remove_docker_images ()
1259
1278
1260
- process_helpers .kill_ps (self .__ps_to_kill )
1279
+ ps_errors = []
1280
+ for ps in self .__ps_to_kill :
1281
+ try :
1282
+ process_helpers .kill_ps (ps ['ps' ], ps ['cmd' ])
1283
+ except ProcessLookupError as exc : # Process might have done expected exit already. However all other errors shall bubble
1284
+ ps_errors .append (f"Could not kill { ps ['cmd' ]} . Exception: { exc } " )
1285
+ if ps_errors :
1286
+ raise RuntimeError (ps_errors )
1287
+
1288
+
1261
1289
print (TerminalColors .OKBLUE , '-Cleanup gracefully completed' , TerminalColors .ENDC )
1262
1290
1263
1291
self .__notes_helper = Notes ()
0 commit comments