fix(gateway): handle Windows OSError in PID liveness prob#11575
Closed
xy200303 wants to merge 7 commits into
Closed
fix(gateway): handle Windows OSError in PID liveness prob#11575xy200303 wants to merge 7 commits into
xy200303 wants to merge 7 commits into
Conversation
4 tasks
Contributor
|
Thanks for the contribution @xy200303! The core fix in this PR — catching Automated hermes-sweeper review found the fix implemented at:
The PR also bundles two unrelated changes ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR fixes a Windows-specific gateway startup failure caused by PID liveness probing.
Hermes uses
os.kill(pid, 0)to check whether a PID recorded in the gateway PID file is still alive. That works in most cases, but on Windows some stale or invalid PIDs can raise a plainOSErrorsuch asWinError 11instead of the expectedProcessLookupErrororPermissionError. Because that case was not handled, gateway startup could crash while checking for an existing process instead of safely treating the PID record as stale.This fix centralizes PID liveness probing in a helper and treats Windows-specific
OSErrorprobe failures as “not alive”. That keeps startup resilient and prevents stale PID files from crashing the gateway.Related Issue
Fixes #
Type of Change
Changes Made
gateway/status.pyto add_pid_looks_alive(pid)for centralized PID liveness checks.OSErrorprobe failures as stale/non-running PIDs instead of crashing.get_running_pid()and scoped lock liveness checks.tests/gateway/test_status.pycovering the WindowsOSErrorPID probe case.How to Test
python -m pytest tests/gateway/test_status.py -qgateway.pidand verify Hermes no longer crashes during startup PID detection.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Test run: