Skip to content

Commit 2c89611

Browse files
committed
fix: ensure proper cleanup in stdio_client
1 parent 568cbd1 commit 2c89611

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/mcp/client/stdio.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,11 @@ async def stdin_writer():
159159
):
160160
tg.start_soon(stdout_reader)
161161
tg.start_soon(stdin_writer)
162-
yield read_stream, write_stream
162+
try:
163+
yield read_stream, write_stream
164+
finally:
165+
for stream in (process.stdin, process.stdout, process.stderr):
166+
if stream:
167+
await stream.aclose()
168+
process.terminate()
169+
await process.aclose()

0 commit comments

Comments
 (0)