MCPcopy Index your code
hub / github.com/commandoperator/cmdop-sdk / _read_delimited

Function _read_delimited

python/src/cmdop/_transport.py:62–77  ·  view source on GitHub ↗

Read one length-delimited protobuf body off ``reader``. Reads the varint length one byte at a time (high bit = continue), then the exact body. ``readexactly`` has no buffer-size cap, so there is no 64 KB readline trap (report 13 §1.4 — this is *why* proto framing replaced NDJSON). R

(reader: asyncio.StreamReader)

Source from the content-addressed store, hash-verified

60
61
62async def _read_delimited(reader: asyncio.StreamReader) -> bytes:
63 """Read one length-delimited protobuf body off ``reader``.
64
65 Reads the varint length one byte at a time (high bit = continue), then the
66 exact body. ``readexactly`` has no buffer-size cap, so there is no 64 KB
67 readline trap (report 13 §1.4 — this is *why* proto framing replaced NDJSON).
68 Raises :class:`asyncio.IncompleteReadError` at EOF.
69 """
70 buf = b""
71 while True:
72 b = await reader.readexactly(1)
73 buf += b
74 if not (b[0] & 0x80):
75 break
76 size, _ = _DecodeVarint32(buf, 0)
77 return await reader.readexactly(size)
78
79
80def _write_delimited(writer: asyncio.StreamWriter, env: pb.Envelope) -> None:

Callers 3

_read_requestFunction · 0.90
_read_requestFunction · 0.90
_read_loopMethod · 0.85

Calls

no outgoing calls

Tested by 2

_read_requestFunction · 0.72
_read_requestFunction · 0.72