fix: unblock event loop for analyze_repo, detach git subprocess stdin on Windows - #112
Merged
anhnh2002 merged 3 commits intoSep 23, 2026
Merged
Conversation
huanceng
commented
Sep 21, 2026
Contributor
- Run analyze_repo via asyncio.to_thread under an asyncio.Lock: keeps tree-sitter usage serialized without blocking the MCP stdio pump (aligns with the to_thread pattern used by all other sync handlers)
- Add stdin=DEVNULL to GitIgnoreFilter's git calls so children never inherit the MCP JSON-RPC stdin pipe, which hangs on Windows ProactorEventLoop
… on Windows - Run analyze_repo via asyncio.to_thread under an asyncio.Lock: keeps tree-sitter usage serialized without blocking the MCP stdio pump (aligns with the to_thread pattern used by all other sync handlers) - Add stdin=DEVNULL to GitIgnoreFilter's git calls so children never inherit the MCP JSON-RPC stdin pipe, which hangs on Windows ProactorEventLoop
…f the main thread Running analyze_repo via asyncio.to_thread exposed a latent bug in the SIGALRM-based timeout() helper: signal.signal() can only be called from the main thread, so from a worker thread it raised (ValueError, then UnboundLocalError in the finally block), which the per-file `except Exception` swallowed at DEBUG level. Every file was skipped and analyze_repo returned 0 components on macOS/Linux. Windows was unaffected because it already fell back through the AttributeError path. - timeout(): skip SIGALRM when it is unavailable or when not on the main thread; run the body without a timeout instead of failing - server.py: reword the lock comment and satisfy ruff format (blank line)
Apply the same stdin=DEVNULL treatment to the git clone/config/checkout calls in cloning.py and github_processor.py so no git child process inherits the parent's stdin (the MCP JSON-RPC pipe when run as a server, or an interactive terminal where git could otherwise block on a prompt).
Collaborator
|
Thanks for the PR, the motivation is right and the stdin change is good hygiene. Moving
|
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.