mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-25 15:04:18 +02:00
Test `test_multi_client_lifespan` was timing out because MCPConfigTransport leaked subprocess resources. **Root cause:** MCPConfigTransport.connect_session() never cleaned up underlying StdioTransport objects. When the client context exited, only the main FastMCPTransport session was closed, but the underlying stdio connections to actual MCP server subprocesses were left open. With keep_alive=True (default), these transports don't auto-disconnect, so subprocess stdin was never closed and processes stayed alive indefinitely. **The fix:** Added finally block to MCPConfigTransport.connect_session() that explicitly calls close() on all underlying transports. This ensures subprocess stdin is closed and processes terminate cleanly. **Evidence:** - Before: 100% timeout rate (processes status='sleeping' after context exit) - After: 15/15 consecutive passes, processes terminate immediately - Test time: 5.2s (timeout) → 3.2s (clean exit) **Secondary fix:** Simplified test logic from infinite polling loop to direct psutil.Process(pid).status() check. The old while-True loop never raised NoSuchProcess because the constructor succeeds for existing processes. All 3271 tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| cli | ||
| client | ||
| contrib | ||
| deprecated | ||
| experimental | ||
| integration_tests | ||
| prompts | ||
| resources | ||
| server | ||
| tools | ||
| utilities | ||
| __init__.py | ||
| conftest.py | ||
| test_examples.py | ||
| test_mcp_config.py | ||