Skip to content

Commit ef5f2fe

Browse files
committed
Use sigkill to prevent zombies
1 parent 20d6466 commit ef5f2fe

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

simvue/executor.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,12 @@ def kill_process(self, process_id: str) -> None:
308308
logger.debug(f"Terminating child process {child.pid}: {child.name()}")
309309
child.kill()
310310

311+
for child in parent.children(recursive=True):
312+
child.wait()
313+
311314
logger.debug(f"Terminating child process {process.pid}: {process.args}")
312-
process.terminate()
315+
process.kill()
316+
process.wait()
313317

314318
self._execute_callback(process_id)
315319

tests/refactor/test_run_class.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,15 @@ def testing_exit(status: int) -> None:
517517
def test_kill_all_processes(create_plain_run: typing.Tuple[sv_run.Run, dict]) -> None:
518518
run, _ = create_plain_run
519519
run.config(resources_metrics_interval=1)
520-
run.add_process(identifier="forever_long", executable="bash", c="sleep 10000")
520+
run.add_process(identifier="forever_long_1", executable="bash", c="sleep 10000")
521+
run.add_process(identifier="forever_long_2", executable="bash", c="sleep 10000")
522+
processes = [
523+
psutil.Process(process.pid)
524+
for process in run._executor._processes.values()
525+
]
521526
time.sleep(2)
522527
run.kill_all_processes()
528+
time.sleep(4)
529+
for process in processes:
530+
assert not process.is_running()
531+
assert all(not child.is_running() for child in process.children(recursive=True))

0 commit comments

Comments
 (0)