MCPcopy Create free account
hub / github.com/commandoperator/cmdop-sdk / _ensure_started

Method _ensure_started

python/src/cmdop/_transport.py:103–129  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

101 self._binary_path,
102 "--stdio",
103 stdin=asyncio.subprocess.PIPE,
104 stdout=asyncio.subprocess.PIPE,
105 stderr=asyncio.subprocess.PIPE,
106 env=env,
107 )
108 self._reader_task = asyncio.create_task(self._read_loop())
109 self._stderr_task = asyncio.create_task(self._drain_stderr())
110
111 async def _drain_stderr(self) -> None:
112 assert self._process is not None and self._process.stderr is not None
113 while await self._process.stderr.readline():
114 pass
115
116 async def _read_loop(self) -> None:
117 assert self._process is not None and self._process.stdout is not None
118 try:
119 while True:
120 envelope = pb.Envelope.FromString(
121 await _read_delimited(self._process.stdout)
122 )
123 self._dispatch(envelope)
124 except asyncio.IncompleteReadError:
125 self._fail_all(CmdopConnectionError("cmdop-core exited", code="transport"))
126 except asyncio.CancelledError:
127 raise
128 except Exception as exc: # noqa: BLE001
129 self._fail_all(
130 CmdopConnectionError(f"core read failed: {exc}", code="transport")
131 )
132

Callers 3

write_answerMethod · 0.95
call_unaryMethod · 0.95
_start_streamMethod · 0.95

Calls 2

_read_loopMethod · 0.95
_drain_stderrMethod · 0.95

Tested by

no test coverage detected