From dfa00d04b6664b33b6d993d79eca9f00287a77a1 Mon Sep 17 00:00:00 2001 From: Artificial Sweetener Date: Sat, 5 Sep 2026 18:35:42 -0400 Subject: [PATCH] ci(types): make Windows process constants portable --- tests/test_comfy_integration_server_process.py | 3 +-- tools/comfy_integration/server_process.py | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_comfy_integration_server_process.py b/tests/test_comfy_integration_server_process.py index ae29a3b..0b8a4f7 100644 --- a/tests/test_comfy_integration_server_process.py +++ b/tests/test_comfy_integration_server_process.py @@ -7,7 +7,6 @@ from __future__ import annotations import io -import signal import subprocess from pathlib import Path from typing import cast @@ -131,7 +130,7 @@ def test_stop_signals_only_the_created_group_and_closes_logs() -> None: process.stop(graceful_timeout=3.0) - assert fake.signals == [signal.CTRL_BREAK_EVENT] + assert fake.signals == [server_process.WINDOWS_CTRL_BREAK_EVENT] assert fake.wait_timeouts == [3.0] assert stdout.closed assert stderr.closed diff --git a/tools/comfy_integration/server_process.py b/tools/comfy_integration/server_process.py index b98b571..9c9f253 100644 --- a/tools/comfy_integration/server_process.py +++ b/tools/comfy_integration/server_process.py @@ -17,6 +17,10 @@ from .loopback_port import validate_loopback_port TASKKILL_ATTEMPTS = 3 TASKKILL_RETRY_DELAY_SECONDS = 0.2 +WINDOWS_CREATE_NEW_PROCESS_GROUP = int( + getattr(subprocess, "CREATE_NEW_PROCESS_GROUP", 0) +) +WINDOWS_CTRL_BREAK_EVENT = int(getattr(signal, "CTRL_BREAK_EVENT", 0)) @dataclass(frozen=True) @@ -94,7 +98,7 @@ class WindowsComfyProcess: stdin=subprocess.DEVNULL, stdout=stdout, stderr=stderr, - creationflags=subprocess.CREATE_NEW_PROCESS_GROUP, + creationflags=WINDOWS_CREATE_NEW_PROCESS_GROUP, ) except BaseException: stdout.close() @@ -122,7 +126,7 @@ class WindowsComfyProcess: try: if self.is_running: try: - self._process.send_signal(signal.CTRL_BREAK_EVENT) + self._process.send_signal(WINDOWS_CTRL_BREAK_EVENT) except OSError: if self.is_running: self._force_stop_if_running()