Read all bytes from the stream. This is a generator-based coroutine. Args: m: Maximum number bytes to read; this is a security limit. Raises: RuntimeError: If the stream ends in more than ``m`` bytes.
(self, m: int)
| 75 | return r |
| 76 | |
| 77 | def read_to_eof(self, m: int) -> Generator[None, None, bytearray]: |
| 78 | """ |
| 79 | Read all bytes from the stream. |
| 80 | |
| 81 | This is a generator-based coroutine. |
| 82 | |
| 83 | Args: |
| 84 | m: Maximum number bytes to read; this is a security limit. |
| 85 | |
| 86 | Raises: |
| 87 | RuntimeError: If the stream ends in more than ``m`` bytes. |
| 88 | |
| 89 | """ |
| 90 | while not self.eof: |
| 91 | p = len(self.buffer) |
| 92 | if p > m: |
| 93 | raise RuntimeError(f"read {p} bytes, expected no more than {m} bytes") |
| 94 | yield |
| 95 | r = self.buffer[:] |
| 96 | del self.buffer[:] |
| 97 | return r |
| 98 | |
| 99 | def at_eof(self) -> Generator[None, None, bool]: |
| 100 | """ |
no outgoing calls