Commit 1ba4065
committed
Simplify the stdio client transport
Restructure stdio_client to read top-down: spawn the server process before
creating the transport streams (a failed spawn now has nothing to clean up),
extract _parse_line, replace the reader's delivering flag with two sequential
phases (deliver, then drain), name the shutdown sequence as a shutdown()
helper with numbered steps, and rename _shutdown_process_tree to
_stop_server_process so it no longer reads as a synonym of
_terminate_process_tree. Add a ServerProcess alias for the process union.
Use the same cancellation idiom as the other client transports for the
bounded waits and task teardown (move_on_after, tg.cancel_scope.cancel())
instead of deadline-poll loops and dedicated per-task scopes; a
cancel_shielded_checkpoint after each site that can throw through the await
chain keeps coverage accurate on Python 3.11 (python/cpython#106749). Drop
four scheduling checkpoints in exception handlers that nothing depends on.
Compress comments to the load-bearing rationale, anchor the shutdown
sequence to the MCP lifecycle specification, and explain why
function-valued ("()"-prefixed) environment variables are skipped.1 parent 17a9dca commit 1ba4065
3 files changed
Lines changed: 236 additions & 285 deletions
0 commit comments