This reads data from the file descriptor. This is a simple implementation suitable for a regular file. Subclasses using ptys or pipes should override it. The timeout parameter is ignored.
(self, size=1, timeout=None)
| 168 | buffer = property(_get_buffer, _set_buffer) |
| 169 | |
| 170 | def read_nonblocking(self, size=1, timeout=None): |
| 171 | """This reads data from the file descriptor. |
| 172 | |
| 173 | This is a simple implementation suitable for a regular file. Subclasses using ptys or pipes should override it. |
| 174 | |
| 175 | The timeout parameter is ignored. |
| 176 | """ |
| 177 | |
| 178 | try: |
| 179 | s = os.read(self.child_fd, size) |
| 180 | except OSError as err: |
| 181 | if err.args[0] == errno.EIO: |
| 182 | # Linux-style EOF |
| 183 | self.flag_eof = True |
| 184 | raise EOF('End Of File (EOF). Exception style platform.') |
| 185 | raise |
| 186 | if s == b'': |
| 187 | # BSD-style EOF |
| 188 | self.flag_eof = True |
| 189 | raise EOF('End Of File (EOF). Empty string style platform.') |
| 190 | |
| 191 | s = self._decoder.decode(s, final=False) |
| 192 | self._log(s, 'read') |
| 193 | return s |
| 194 | |
| 195 | def _pattern_type_err(self, pattern): |
| 196 | raise TypeError('got {badtype} ({badobj!r}) as pattern, must be one' |