refactor(serve): one place maps "process gone" to orphaned in the watchdog
The inner ProcessLookupError handler around the marker probe made the outer one reachable only through an injected pid_exists that raises (gateway.status._pid_exists never does). Keep the single mapping; the degrade-to-liveness fixture no longer models a stderr the probe now classifies as a missing process.
This commit is contained in:
@@ -75,9 +75,8 @@ def _process_start_marker(pid: int) -> str:
|
||||
marker = result.stdout.strip()
|
||||
if result.returncode == 0 and marker:
|
||||
return f"ps:{marker}"
|
||||
# rc==1 with empty output is the portable "no such pid"; "No such process" widens that for ps
|
||||
# builds that say so explicitly. Any other failure stays an OSError so the watchdog degrades to
|
||||
# pid liveness instead of exiting on a healthy backend.
|
||||
# Only known "missing pid" signals become ProcessLookupError; anything else stays OSError so the
|
||||
# watchdog degrades to pid liveness instead of exiting on a healthy backend.
|
||||
if (result.returncode == 1 and not marker) or "no such process" in result.stderr.lower():
|
||||
raise ProcessLookupError(pid)
|
||||
raise OSError(f"ps could not inspect PID {pid}: {result.stderr.strip()}")
|
||||
@@ -300,8 +299,6 @@ def _is_serve_orphaned(
|
||||
|
||||
pid_exists = _pid_exists
|
||||
return not bool(pid_exists(int(desktop_pid)))
|
||||
except ProcessLookupError:
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ def test_parent_watchdog_degrades_to_pid_liveness_when_marker_probe_raises_oserr
|
||||
"""#80204: a probe failure must fall through to ``pid_exists`` instead of pinning the
|
||||
watchdog to "not orphaned" forever on a dead Desktop parent."""
|
||||
def broken_marker_probe(pid: int) -> str:
|
||||
raise OSError(f"ps could not inspect PID {pid}: ps: {pid}: No such process")
|
||||
raise OSError(f"ps could not inspect PID {pid}: process table temporarily unavailable")
|
||||
|
||||
marker = "ps:Thu Aug 20 22:33:11 2026"
|
||||
assert _is_serve_orphaned(4242, marker, pid_exists=lambda _pid: False,
|
||||
|
||||
Reference in New Issue
Block a user