From b1d526b775c2bdd625bb5f4347d516a1371d937e Mon Sep 17 00:00:00 2001 From: Donato Capitella Date: Fri, 15 May 2026 08:43:34 +0100 Subject: [PATCH] feat: add SIGINT handler for container cleanup and enable replace flag for podman execution --- benchmark/run_mtp_bench.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/benchmark/run_mtp_bench.py b/benchmark/run_mtp_bench.py index 98c6107..a9e4919 100755 --- a/benchmark/run_mtp_bench.py +++ b/benchmark/run_mtp_bench.py @@ -66,6 +66,17 @@ COOLDOWN = 5 # seconds between runs BENCH_SCRIPT = Path(__file__).parent / "mtp-bench.py" +def _sigint_handler(sig, frame): + """Clean up container on Ctrl+C.""" + print("\n\nšŸ›‘ Interrupted — cleaning up container...") + subprocess.run(["podman", "stop", "-t", "3", CONTAINER_NAME], capture_output=True) + subprocess.run(["podman", "rm", "-f", CONTAINER_NAME], capture_output=True) + sys.exit(1) + +import signal +signal.signal(signal.SIGINT, _sigint_handler) + + # ── Model discovery ────────────────────────────────────────────────────────── def discover_models(models_dir: Path) -> list[dict]: @@ -207,7 +218,7 @@ def start_server(toolbox: dict, gguf: str, models_dir: Path, return False cmd = [ - "podman", "run", "--rm", "-d", + "podman", "run", "--rm", "--replace", "-d", "--name", CONTAINER_NAME, "--security-opt", "label=disable", "--userns=keep-id",