MCPcopy
hub / github.com/modelcontextprotocol/python-sdk / _wait_for_process_exit

Function _wait_for_process_exit

src/mcp/client/stdio.py:276–287  ·  view source on GitHub ↗

Returns whether the process died within the timeout, by polling returncode. Not process.wait(): on asyncio 3.11+ it also waits for pipe EOF, and a child that inherited the pipes makes an exited server look hung.

(process: ServerProcess, timeout: float)

Source from the content-addressed store, hash-verified

274
275
276async def _wait_for_process_exit(process: ServerProcess, timeout: float) -> bool:
277 """Returns whether the process died within the timeout, by polling returncode.
278
279 Not process.wait(): on asyncio 3.11+ it also waits for pipe EOF, and a
280 child that inherited the pipes makes an exited server look hung.
281 """
282 deadline = anyio.current_time() + timeout
283 while process.returncode is None:
284 if anyio.current_time() >= deadline:
285 return False
286 await anyio.sleep(_EXIT_POLL_INTERVAL)
287 return True
288
289
290async def _terminate_process_tree(process: ServerProcess) -> None:

Callers 1

_stop_server_processFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected