diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-01-29 13:40:58 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-01-29 13:40:58 +0100 |
commit | 5fe382d0e916c63d7f2e72a9b5361058501f5b2b (patch) | |
tree | 72a3c79d2a7a776ace740c007675cfe37e3424c1 /asyncio/unix_events.py | |
parent | c66282230e3966e45ff22374096bc3a1761e3236 (diff) | |
download | trollius-git-5fe382d0e916c63d7f2e72a9b5361058501f5b2b.tar.gz |
Fix _UnixReadPipeTransport and _UnixWritePipeTransport
Only start reading when connection_made() has been called.
Diffstat (limited to 'asyncio/unix_events.py')
-rw-r--r-- | asyncio/unix_events.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/asyncio/unix_events.py b/asyncio/unix_events.py index 67973f1..7e1265a 100644 --- a/asyncio/unix_events.py +++ b/asyncio/unix_events.py @@ -298,8 +298,10 @@ class _UnixReadPipeTransport(transports.ReadTransport): _set_nonblocking(self._fileno) self._protocol = protocol self._closing = False - self._loop.add_reader(self._fileno, self._read_ready) self._loop.call_soon(self._protocol.connection_made, self) + # only start reading when connection_made() has been called + self._loop.call_soon(self._loop.add_reader, + self._fileno, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(waiter._set_result_unless_cancelled, None) @@ -401,13 +403,16 @@ class _UnixWritePipeTransport(transports._FlowControlMixin, self._conn_lost = 0 self._closing = False # Set when close() or write_eof() called. - # On AIX, the reader trick only works for sockets. - # On other platforms it works for pipes and sockets. - # (Exception: OS X 10.4? Issue #19294.) + self._loop.call_soon(self._protocol.connection_made, self) + + # On AIX, the reader trick (to be notified when the read end of the + # socket is closed) only works for sockets. On other platforms it + # works for pipes and sockets. (Exception: OS X 10.4? Issue #19294.) if is_socket or not sys.platform.startswith("aix"): - self._loop.add_reader(self._fileno, self._read_ready) + # only start reading when connection_made() has been called + self._loop.call_soon(self._loop.add_reader, + self._fileno, self._read_ready) - self._loop.call_soon(self._protocol.connection_made, self) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(waiter._set_result_unless_cancelled, None) |