From b8338f7b66a9991417d6aac83e25d555fe56be93 Mon Sep 17 00:00:00 2001 From: Tomas Martykan Date: Fri, 6 Sep 2024 10:58:55 +0200 Subject: [PATCH] fix: bridge proxy kill children as well --- src/bridge_proxy.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bridge_proxy.py b/src/bridge_proxy.py index 4cd4799..3e94763 100644 --- a/src/bridge_proxy.py +++ b/src/bridge_proxy.py @@ -34,9 +34,9 @@ def start() -> None: file_path = os.path.join(os.path.dirname(__file__), "bridge_proxy_server.py") - command = f"python {file_path}" + command_list = ["python", file_path] - BRIDGE_PROXY = Popen(command, shell=True) + BRIDGE_PROXY = Popen(command_list) log(f"Bridge proxy spawned: {BRIDGE_PROXY}. CMD: {BRIDGE_PROXY.cmdline()}") # Verifying if the proxy is really running @@ -54,4 +54,9 @@ def stop() -> None: else: BRIDGE_PROXY.kill() log(f"Bridge proxy killed: {BRIDGE_PROXY}") + # Ensuring all child processes are cleaned up + for child in BRIDGE_PROXY.children(recursive=True): + log(f"Killing child process {child.pid}") + child.kill() + child.wait() BRIDGE_PROXY = None