Repository navigation
Run tools off the event loop so one stuck call can't stall the server - #8
Merged
Merged
Conversation
FastMCP calls a plain (sync) tool directly on the event loop. Every tool here is sync and waits on the COM bridge, which can take minutes when AutoCAD sits at a dialog, so during that time the server answered nothing else: not /health, not another client, not a retry. The logging wrapper the tools already go through is now async and runs the tool with anyio.to_thread.run_sync. The COM bridge still serialises the AutoCAD work on its own thread, so nothing changes about how AutoCAD is called. New test in test_assembled_server holds a tool call inside bridge.run and checks /health answers meanwhile; it fails on main and passes here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
FastMCP runs sync tools straight on the event loop, and every tool here is sync and waits on the COM bridge. So while one call sat behind an AutoCAD dialog (up to the 120-300 s timeout), the server answered nothing else, /health included. The logging wrapper is now async and runs the tool on a worker thread with anyio; the COM bridge still serialises the AutoCAD work on its own thread, so how AutoCAD is called doesn't change.
The new test in test_assembled_server holds a call inside bridge.run and checks /health answers meanwhile. It fails on main and passes here (5 runs), full suite 49 OK locally. Error results still come back with their message. Not tested against a live AutoCAD.