Skip to content

Commit ab8eec9

Browse files
Fix Windows test hanging due to double process termination
The FallbackProcess.__aexit__ method was automatically terminating processes on context exit, which conflicted with stdio_client's explicit cleanup sequence. This caused the test_stdio_client_universal_cleanup test to hang on Windows. The fix removes automatic termination from FallbackProcess.__aexit__, allowing stdio_client to handle the MCP spec-compliant shutdown sequence: 1. Close stdin and wait for graceful exit 2. Send terminate signal if needed 3. Force kill as last resort This prevents the double termination attempt that was causing hangs. Reported-by: fweinberger
1 parent ecfd6af commit ab8eec9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/mcp/client/stdio/win32.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ async def __aexit__(
7373
exc_val: BaseException | None,
7474
exc_tb: object | None,
7575
) -> None:
76-
"""Terminate and wait on process exit inside a thread."""
77-
self.popen.terminate()
78-
await to_thread.run_sync(self.popen.wait)
79-
76+
"""Clean up streams without terminating the process.
77+
78+
The process termination is handled by stdio_client's cleanup sequence
79+
which implements the MCP spec-compliant shutdown flow.
80+
"""
8081
# Close the file handles to prevent ResourceWarning
8182
if self.stdin:
8283
await self.stdin.aclose()

0 commit comments

Comments
 (0)