From b702ac633f149ada9ea123a8bfda5871d7ef6033 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Sun, 18 Oct 2026 22:00:42 +0800 Subject: [PATCH] test(gateway): publish child claim markers atomically --- tests/gateway/test_runtime.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/gateway/test_runtime.py b/tests/gateway/test_runtime.py index dd5e981bb..ef03d57e2 100644 --- a/tests/gateway/test_runtime.py +++ b/tests/gateway/test_runtime.py @@ -68,6 +68,11 @@ duration = float(sys.argv[2]) marker = Path(sys.argv[3]) runtime = GatewayRuntime(paths=GatewayRuntimePaths.for_instance(data_dir=root)) +def publish_marker(detail): + pending = marker.with_suffix(".tmp") + pending.write_text(detail, encoding="utf-8") + pending.replace(marker) + def stop(*_args): raise SystemExit(0) @@ -75,13 +80,13 @@ try: if os.name != "nt": signal.signal(signal.SIGTERM, stop) with runtime.foreground_instance(GatewayStartOptions(port=18790)): - marker.write_text(f"claimed:{os.getpid()}", encoding="utf-8") + publish_marker(f"claimed:{os.getpid()}") time.sleep(duration) except GatewayAlreadyRunningError: - marker.write_text("occupied", encoding="utf-8") + publish_marker("occupied") raise SystemExit(17) except BaseException as exc: - marker.write_text(f"error:{type(exc).__name__}:{exc}", encoding="utf-8") + publish_marker(f"error:{type(exc).__name__}:{exc}") raise """