From 9bb5a809b52aa519f7e8cefe48faedcad0f7eb2e Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Sun, 28 Jun 2026 03:11:03 -0700 Subject: [PATCH] fix(gateway): make zombie check defensive against partial psutil stubs The zombie status probe referenced psutil.Process/NoSuchProcess/Error unconditionally, which raised AttributeError when psutil is a partial stub that only defines pid_exists (as in test_windows_native_support's fallback tests). Guard the probe so any failure to read status degrades to the authoritative pid_exists() instead of raising. --- gateway/status.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gateway/status.py b/gateway/status.py index c0798065afe..81e5be95f4d 100644 --- a/gateway/status.py +++ b/gateway/status.py @@ -555,13 +555,16 @@ def _pid_exists(pid: int) -> bool: # with exit 1 — a silent crash loop under systemd ``Restart=always``, # which respawns the gateway before reaping the previous process # (issue #42126). Report zombies as dead so the takeover proceeds. + # Best-effort: any failure to read status (partial/stub psutil, + # access denied, transient race) falls through to the authoritative + # ``pid_exists()`` below rather than raising. try: if psutil.Process(int(pid)).status() == psutil.STATUS_ZOMBIE: return False - except psutil.NoSuchProcess: + except getattr(psutil, "NoSuchProcess", ()): return False - except psutil.Error: - pass # Access denied / transient — defer to pid_exists below. + except Exception: + pass return bool(psutil.pid_exists(int(pid))) except ImportError: