MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / send

Method send

tests/client/test_stdio.py:62–75  ·  view source on GitHub ↗
(self, data: bytes)

Source from the content-addressed store, hash-verified

60 self._process = process
61
62 async def send(self, data: bytes) -> None:
63 if self._process.stdin_send_gate is not None:
64 # A full pipe whose reader is busy elsewhere: the write completes
65 # only once the test's gate opens.
66 await self._process.stdin_send_gate.wait()
67 if self._process.stdin_send_blocks:
68 # A pipe whose reader stopped reading: the write never completes.
69 await anyio.sleep_forever()
70 if self._process.stdin_send_error is not None:
71 raise self._process.stdin_send_error
72 if self._process.returncode is not None:
73 # What the asyncio backend surfaces when writing to a dead child's pipe.
74 raise ConnectionResetError("Connection lost")
75 self._process.written.append(data)
76
77 async def aclose(self) -> None:
78 self._process.stdin_closed.set()

Calls 1

waitMethod · 0.80

Tested by

no test coverage detected