fix(windows): probe compute host liveness without sending signals
This commit is contained in:
1 parent
3f12c627ab
commit
ac6687181e
2 files changed
+26
-11
No files matched your search
@@ -22,6 +22,8 @@ from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import psutil
|
||||
|
||||
from hermes_constants import get_hermes_home
|
||||
from tools.environments.local import hermes_subprocess_env
|
||||
|
||||
@@ -112,17 +114,9 @@ def _default_registry_path() -> Path:
|
||||
|
||||
|
||||
def _pid_alive(pid: int) -> bool:
|
||||
if pid <= 0:
|
||||
return False
|
||||
try:
|
||||
os.kill(pid, 0)
|
||||
return True
|
||||
except ProcessLookupError:
|
||||
return False
|
||||
except PermissionError:
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
# Signal zero is not a portable liveness query (CTRL_C_EVENT on Windows).
|
||||
# pid_exists also distinguishes exited Windows processes with open handles.
|
||||
return pid > 0 and psutil.pid_exists(pid)
|
||||
|
||||
|
||||
def _pid_command(pid: int) -> str:
|
||||
|
||||
Reference in new issue
Block a user