| 486 | max_size = 256 * 1024 # max bytes we read in one event loop iteration |
| 487 | |
| 488 | def __init__(self, loop, pipe, protocol, waiter=None, extra=None): |
| 489 | super().__init__(extra) |
| 490 | self._extra['pipe'] = pipe |
| 491 | self._loop = loop |
| 492 | self._pipe = pipe |
| 493 | self._fileno = pipe.fileno() |
| 494 | self._protocol = protocol |
| 495 | self._closing = False |
| 496 | self._paused = False |
| 497 | |
| 498 | mode = os.fstat(self._fileno).st_mode |
| 499 | if not (stat.S_ISFIFO(mode) or |
| 500 | stat.S_ISSOCK(mode) or |
| 501 | stat.S_ISCHR(mode)): |
| 502 | self._pipe = None |
| 503 | self._fileno = None |
| 504 | self._protocol = None |
| 505 | raise ValueError("Pipe transport is for pipes/sockets only.") |
| 506 | |
| 507 | os.set_blocking(self._fileno, False) |
| 508 | |
| 509 | self._loop.call_soon(self._protocol.connection_made, self) |
| 510 | # only start reading when connection_made() has been called |
| 511 | self._loop.call_soon(self._add_reader, |
| 512 | self._fileno, self._read_ready) |
| 513 | if waiter is not None: |
| 514 | # only wake up the waiter when connection_made() has been called |
| 515 | self._loop.call_soon(futures._set_result_unless_cancelled, |
| 516 | waiter, None) |
| 517 | |
| 518 | def _add_reader(self, fd, callback): |
| 519 | if not self.is_reading(): |