mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-01 12:02:05 +00:00
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.
This commit is contained in:
parent
acca526286
commit
9bb5a809b5
1 changed files with 6 additions and 3 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue