@@ -173,7 +173,7 @@ class Launcher:
173
173
env_file : str | os .PathLike | None = None
174
174
timeout : int = 600
175
175
176
- def run (
176
+ def run ( # noqa: C901, PLR0912
177
177
self ,
178
178
func : Callable ,
179
179
func_args : tuple [Any ] | None = None ,
@@ -206,6 +206,7 @@ def run(
206
206
log_receiver = None
207
207
log_process = None
208
208
launcher_agent_group = None
209
+ agent_payloads = None
209
210
210
211
try :
211
212
# start logging server
@@ -287,25 +288,25 @@ def run(
287
288
288
289
if all (s .state == "done" for s in agent_statuses ):
289
290
break
290
-
291
- except :
292
- # cleanup: SIGTERM all agents
293
- for agent_payload , agent_hostname in zip (agent_payloads , hostnames ):
294
- execute_command (
295
- command = f"kill { agent_payload .process_id } " ,
296
- hostname = agent_hostname ,
297
- ssh_config_file = self .ssh_config_file ,
298
- )
299
- raise
300
291
finally :
301
292
if log_receiver is not None :
302
293
log_receiver .shutdown ()
303
- log_receiver .server_close ()
304
- if log_process is not None :
305
- log_process .kill ()
294
+ if log_process is not None :
295
+ log_receiver .server_close ()
296
+ log_process .kill ()
297
+
306
298
if launcher_agent_group is not None :
307
299
launcher_agent_group .shutdown ()
308
300
301
+ # cleanup: SIGTERM all agents
302
+ if agent_payloads is not None :
303
+ for agent_payload , agent_hostname in zip (agent_payloads , hostnames ):
304
+ execute_command (
305
+ command = f"kill { agent_payload .process_id } " ,
306
+ hostname = agent_hostname ,
307
+ ssh_config_file = self .ssh_config_file ,
308
+ )
309
+
309
310
return {
310
311
hostname : agent_status .return_values
311
312
for hostname , agent_status in zip (hostnames , agent_statuses )
0 commit comments