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)
| 60 | |
| 61 | |
| 62 | async 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 | |
| 80 | def _write_delimited(writer: asyncio.StreamWriter, env: pb.Envelope) -> None: |
no outgoing calls