(self, loop, pipe, protocol, waiter=None, extra=None)
| 629 | transports.WriteTransport): |
| 630 | |
| 631 | def __init__(self, loop, pipe, protocol, waiter=None, extra=None): |
| 632 | super().__init__(extra, loop) |
| 633 | self._extra['pipe'] = pipe |
| 634 | self._pipe = pipe |
| 635 | self._fileno = pipe.fileno() |
| 636 | self._protocol = protocol |
| 637 | self._buffer = bytearray() |
| 638 | self._conn_lost = 0 |
| 639 | self._closing = False # Set when close() or write_eof() called. |
| 640 | |
| 641 | mode = os.fstat(self._fileno).st_mode |
| 642 | is_char = stat.S_ISCHR(mode) |
| 643 | is_fifo = stat.S_ISFIFO(mode) |
| 644 | is_socket = stat.S_ISSOCK(mode) |
| 645 | if not (is_char or is_fifo or is_socket): |
| 646 | self._pipe = None |
| 647 | self._fileno = None |
| 648 | self._protocol = None |
| 649 | raise ValueError("Pipe transport is only for " |
| 650 | "pipes, sockets and character devices") |
| 651 | |
| 652 | os.set_blocking(self._fileno, False) |
| 653 | self._loop.call_soon(self._protocol.connection_made, self) |
| 654 | |
| 655 | # On AIX, the reader trick (to be notified when the read end of the |
| 656 | # socket is closed) only works for sockets. On other platforms it |
| 657 | # works for pipes and sockets. (Exception: OS X 10.4? Issue #19294.) |
| 658 | if is_socket or (is_fifo and not sys.platform.startswith("aix")): |
| 659 | # only start reading when connection_made() has been called |
| 660 | self._loop.call_soon(self._loop._add_reader, |
| 661 | self._fileno, self._read_ready) |
| 662 | |
| 663 | if waiter is not None: |
| 664 | # only wake up the waiter when connection_made() has been called |
| 665 | self._loop.call_soon(futures._set_result_unless_cancelled, |
| 666 | waiter, None) |
| 667 | |
| 668 | def __repr__(self): |
| 669 | info = [self.__class__.__name__] |
nothing calls this directly
no test coverage detected