fix(windows): hide console windows from subprocess spawns - #54082
Closed
MichaelQee wants to merge 2 commits into
Closed
fix(windows): hide console windows from subprocess spawns#54082MichaelQee wants to merge 2 commits into
MichaelQee wants to merge 2 commits into
Conversation
Three Windows-specific fixes for console window flashes: 1. tui_gateway/server.py: Add CREATE_NO_WINDOW to _SlashWorker's subprocess.Popen call. The worker is restarted after every agent turn, and the missing flag caused a visible python.exe window to flash each time. 2. gateway/status.py: Skip ps.exe fallback in _read_process_cmdline on Windows. Git Bash ships ps.exe, so the 'Windows has no ps' assumption is incorrect. Go straight to psutil instead. 3. hermes_cli/gateway.py: (a) Same ps.exe guard in _get_parent_pid. (b) Set WindowsSelectorEventLoopPolicy before asyncio.run() in run_gateway so aiohttp/aiodns works with weixin on Windows.
tonydwb
reviewed
Jun 28, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: LGTM
Hides console windows from subprocess spawns on Windows. Three targeted fixes across different subsystems.
Changes
gateway/status.py: Uses psutil instead ofpscommand on Windows (avoids Git Bash console flash)hermes_cli/gateway.py: Skips ps fallback on Windows, adds WindowsSelectorEventLoopPolicy for aiohttptui_gateway/server.py: AddsCREATE_NO_WINDOWflag to subprocess.Popen
Looks Good
- psutil is already a dependency, clean fallback
- WindowsSelectorEventLoopPolicy fix is well-documented (aiohttp/aiodns compatibility)
- CREATE_NO_WINDOW flag prevents console flashes from TUI gateway
- Platform-specific guards are correctly conditioned on sys.platform
Reviewed by Hermes Agent
Contributor
|
Closing as superseded by the consolidated Windows console-flash work tracked in #54220. The relevant pieces from this PR/cluster have now landed through the targeted follow-up PRs #54236, #53892, and #54417, or are recorded in the umbrella tracker for any remaining native-Windows verification. Keeping this separate PR open would duplicate the tracker and the merged follow-up work. Thanks for digging into this — the reports and PRs in this cluster helped identify the remaining spawn legs. |
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?
Fixes three Windows-specific console window flash issues:
_SlashWorkerpost-turn restart —subprocess.Popenintui_gateway/server.pywas missingcreationflags=subprocess.CREATE_NO_WINDOW. Every agent turn restarted the worker, flashing a Python window each time.ps.exefallback in process checks —gateway/status.pyandhermes_cli/gateway.pyhad code comments saying "Windows has no ps", but Git Bash installsps.exeatC:\Git\usr\bin\ps.exe. The fallback executedpsin a visible console window. Fixed by skippingpson Windows and usingpsutildirectly.Weixin aiodns SelectorEventLoop error —
aiohttpon Windows requiresWindowsSelectorEventLoopPolicy, which wasn't set beforeasyncio.run()inrun_gateway(). This caused weixin/微信 connections to fail with "aiodns needs a SelectorEventLoop". Fixed by setting the policy at startup.Related Issue
Fixes #
Type of Change
Changes Made
tui_gateway/server.py: Addcreationflags=CREATE_NO_WINDOWto_SlashWorker.__init__Popen callgateway/status.py: Skipps.exefallback in_read_process_cmdlineon Windows, use psutilhermes_cli/gateway.py: (1) Addsys.platform == "win32"guard to_get_parent_pidps fallback. (2) SetWindowsSelectorEventLoopPolicybeforeasyncio.run()inrun_gatewayHow to Test
hermes gateway runand observe no blankps.exewindow at 30-second intervals.connectsucceeds instead of failing with "aiodns needs SelectorEventLoop".Checklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.example— or N/ACONTRIBUTING.mdorAGENTS.md— or N/A