-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix/mcp_session_auto_close_when_Mcpworkbench_deleted #6497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix/mcp_session_auto_close_when_Mcpworkbench_deleted #6497
Conversation
Do you think this might fix #6467? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6497 +/- ##
==========================================
- Coverage 78.75% 78.75% -0.01%
==========================================
Files 225 225
Lines 16581 16589 +8
==========================================
+ Hits 13058 13064 +6
- Misses 3523 3525 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
While attempting to improve code coverage, I discovered that the previous fallback logic in del (used to stop the actor if McpWorkbench is GC’ed) did not behave correctly under certain loop conditions. As a result, the shutdown logic has been rewritten. This change simplifies the behavior, avoids misleading fallback attempts, and ensures the shutdown path is verifiable via testing (e.g., pytest.warns()). |
@jackgerrits That said, I’m not entirely confident about the lifecycle behavior on Windows — I’m not a specialist in how del interacts with the asyncio loop on that platform. Ideally, McpWorkbench should be used via async with, in which case aexit guarantees proper shutdown of the MCP session. The fact that it doesn’t close cleanly in #6467 is quite weird and deserves separate investigation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, thanks!
Why are these changes needed?
As-is: Deleting
McpWorkbench
does not close theMcpSession
.To-be: Deleting
McpWorkbench
now properly closes theMcpSession
.Related issue number
Checks