From 4097919531a89b3277788ffb63caa944d28a4f26 Mon Sep 17 00:00:00 2001 From: Modesto Remon Date: Tue, 6 Oct 2026 16:02:36 -0400 Subject: [PATCH] fix(runtime): stop the Windows daemon from opening a visible console Windows ignores CREATE_NO_WINDOW when it is combined with DETACHED_PROCESS. The venv python.exe is a launcher, so the real interpreter it starts got a new visible console, and closing that window killed the server. Fixes #172 --- artemis/runtime/daemon_client.py | 6 +----- tests/unit/runtime/test_daemon_client.py | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/artemis/runtime/daemon_client.py b/artemis/runtime/daemon_client.py index 85471489c..22605677b 100644 --- a/artemis/runtime/daemon_client.py +++ b/artemis/runtime/daemon_client.py @@ -139,11 +139,7 @@ def spawn_daemon( } if sys.platform == "win32": - kwargs["creationflags"] = ( - subprocess.CREATE_NEW_PROCESS_GROUP - | getattr(subprocess, "DETACHED_PROCESS", 0x00000008) - | getattr(subprocess, "CREATE_NO_WINDOW", 0x08000000) - ) + kwargs["creationflags"] = subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.CREATE_NO_WINDOW else: kwargs["start_new_session"] = True diff --git a/tests/unit/runtime/test_daemon_client.py b/tests/unit/runtime/test_daemon_client.py index 67a90d3bb..de3d438b7 100644 --- a/tests/unit/runtime/test_daemon_client.py +++ b/tests/unit/runtime/test_daemon_client.py @@ -54,6 +54,7 @@ def test_is_daemon_running_failure(): def test_spawn_daemon(tmp_path): + import subprocess import sys mock_proc = MagicMock() @@ -74,6 +75,10 @@ def test_spawn_daemon(tmp_path): assert cmd[0] == sys.executable assert cmd[1:3] == ["-m", "apps.admin_console.server"] assert cmd[3:] == ["--host", "127.0.0.1", "--port", "9123"] + if sys.platform == "win32": + assert mock_popen.call_args.kwargs["creationflags"] == ( + subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.CREATE_NO_WINDOW + ) def test_ensure_daemon_running_when_already_active():