Repository navigation
fix(mcp): first tool call hung on Windows while numpy loaded (2.149.1) - #203
Merged
Merged
Conversation
The c3-initial-index thread loaded numpy's native module through chromadb while the server started its other threads; on Windows that deadlocked both, and the first tool call or c3_session save never answered. The server now imports numpy on the main thread before any background thread starts. test_codex_mcp_transport.py: 0/10 passes before, 10/10 after on the affected box; full suite 4607 passed. Claude-Session: https://claude.ai/code/session_01F6QMHB2mkrDJiQWfC1g9wy
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.
On this Windows machine, the MCP server's first tool call (or the first
c3_session save) sometimes never answered, and today it happened every time.tests/test_codex_mcp_transport.pyfailed 10 out of 10 runs on unchangedmain.py-spy on the hung server showed:
c3-initial-indexstuck loading numpy's native module (numpy/_core/multiarray.py, reached throughchromadbfromservices/embedding_index.py:143)Thread.startin_ensure_repo_map_once, waiting for a new thread that never ranLoading the native module in one thread while the process starts others deadlocks both. numpy imports in 0.07 s on its own, and capping OpenBLAS threads doesn't help.
Fix:
lifespanimports numpy on the main thread before any background thread exists. That adds about 75 ms at startup, and the import is skipped if numpy isn't installed.Result on the same machine: 10 out of 10 passes (about 4.7 s each), up from 0 out of 10 (each timing out after 34 s). Full suite: 4607 passed, 7 skipped. ruff clean.
https://claude.ai/code/session_01F6QMHB2mkrDJiQWfC1g9wy