diff --git a/gateway/status.py b/gateway/status.py index 4cdf8f8109..9e373564d4 100644 --- a/gateway/status.py +++ b/gateway/status.py @@ -496,7 +496,8 @@ def acquire_scoped_lock(scope: str, identity: str, metadata: Optional[dict[str, if not stale: try: os.kill(existing_pid, 0) - except (ProcessLookupError, PermissionError): + except (ProcessLookupError, PermissionError, OSError): + # Windows raises OSError with WinError 87 for invalid pid check stale = True else: current_start = _get_process_start_time(existing_pid) @@ -743,6 +744,10 @@ def get_running_pid( if _record_looks_like_gateway(record): return pid continue + except OSError: + # Windows raises OSError with WinError 87 for an invalid pid + # (process is definitely gone). Treat as "process doesn't exist". + continue recorded_start = record.get("start_time") current_start = _get_process_start_time(pid)