fix(web-server): absorb _warm_gateway_module import before lifespan yield (#73083) - #73291
Closed
JonthanaHanh wants to merge 1 commit into
Closed
fix(web-server): absorb _warm_gateway_module import before lifespan yield (#73083)#73291JonthanaHanh wants to merge 1 commit into
JonthanaHanh wants to merge 1 commit into
Conversation
…ield (NousResearch#73083) On Windows + Python 3.11 the gateway import triggers heavy .pyc compilation and Defender real-time scans that do not release the GIL. Running in run_in_executor still froze the event loop for 15-22 s, causing the Desktop's 10-second WebSocket ready-probe to time out. Move the call from the executor to a synchronous invocation before the lifespan yield, so the GIL block is absorbed during backend initialisation — before the server socket accepts probes. Fixes NousResearch#73083
Collaborator
kshitijk4poor
added a commit
to kshitijk4poor/hermes-agent
that referenced
this pull request
Jul 29, 2026
…#73083) The old test asserted _warm_gateway_module was fire-and-forget (startup completes in << SLOW_SECONDS). PR NousResearch#73291 intentionally reversed this: the import now runs synchronously before the lifespan yield because run_in_executor didn't release the GIL on Windows + Python 3.11. Updated the test to assert startup blocks for >= SLOW_SECONDS.
kshitijk4poor
added a commit
that referenced
this pull request
Jul 29, 2026
The old test asserted _warm_gateway_module was fire-and-forget (startup completes in << SLOW_SECONDS). PR #73291 intentionally reversed this: the import now runs synchronously before the lifespan yield because run_in_executor didn't release the GIL on Windows + Python 3.11. Updated the test to assert startup blocks for >= SLOW_SECONDS.
Collaborator
|
Merged via #73907 — your sync warmup fix was salvaged with authorship preserved. Thanks for the contribution! |
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
…#73083) The old test asserted _warm_gateway_module was fire-and-forget (startup completes in << SLOW_SECONDS). PR NousResearch#73291 intentionally reversed this: the import now runs synchronously before the lifespan yield because run_in_executor didn't release the GIL on Windows + Python 3.11. Updated the test to assert startup blocks for >= SLOW_SECONDS.
33hodl
pushed a commit
to 33hodl/hermes-agent
that referenced
this pull request
Aug 12, 2026
…#73083) The old test asserted _warm_gateway_module was fire-and-forget (startup completes in << SLOW_SECONDS). PR NousResearch#73291 intentionally reversed this: the import now runs synchronously before the lifespan yield because run_in_executor didn't release the GIL on Windows + Python 3.11. Updated the test to assert startup blocks for >= SLOW_SECONDS.
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.
Summary
On Windows + Python 3.11, the
_warm_gateway_module()call inhermes_cli/web_server.pyusesrun_in_executorto importhermes_cli.gatewayin a background thread. The intent was to avoid blocking the event loop during .pyc compilation and Defender real-time scans.However, the heavy .pyc file reads do not release the GIL, so the event loop still freezes for 15–22 seconds. The Desktop Electron app's 10-second WebSocket ready-probe times out during this stall, causing a "Could not connect to Hermes gateway" error on startup.
Fix
Move
_warm_gateway_module()fromrun_in_executorto a synchronous call before the lifespan yield. The GIL block is now absorbed during backend initialisation — before the server socket accepts probes — so the Desktop's probe timeout is never triggered.Changes
hermes_cli/web_server.py: Replaceasyncio.get_event_loop().run_in_executor(None, _warm_gateway_module)with_warm_gateway_module(), update comment to explain the GIL-related rationale.Test Plan
hermes dashboardstill works (the warm import is simply synchronous now)Fixes #73083