Read size bytes. Returns exactly size bytes of data unless the underlying raw IO stream reaches EOF or if the call would block in non-blocking mode. If size is negative, read until EOF or until read() would block.
(self, size=None)
| 1063 | self._read_pos = 0 |
| 1064 | |
| 1065 | def read(self, size=None): |
| 1066 | """Read size bytes. |
| 1067 | |
| 1068 | Returns exactly size bytes of data unless the underlying raw IO |
| 1069 | stream reaches EOF or if the call would block in non-blocking |
| 1070 | mode. If size is negative, read until EOF or until read() would |
| 1071 | block. |
| 1072 | """ |
| 1073 | if size is not None and size < -1: |
| 1074 | raise ValueError("invalid number of bytes to read") |
| 1075 | with self._read_lock: |
| 1076 | return self._read_unlocked(size) |
| 1077 | |
| 1078 | def _read_unlocked(self, n=None): |
| 1079 | nodata_val = b"" |