diff options
author | Yury Selivanov <yury@magic.io> | 2016-06-11 15:20:50 (GMT) |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2016-06-11 15:20:50 (GMT) |
commit | 6588712bf02e8e9ee374c92e2c1333f2f0029dc2 (patch) | |
tree | 7543738040db0b2e23440e138f4abf788208cbb3 /Lib/asyncio/selector_events.py | |
parent | b1c9b64850f6b0da3bfe4d0f753f739637c87d78 (diff) | |
parent | ca2e0a48cf0dd663ba7457dc6bce60988cdfd56c (diff) | |
download | cpython-6588712bf02e8e9ee374c92e2c1333f2f0029dc2.zip cpython-6588712bf02e8e9ee374c92e2c1333f2f0029dc2.tar.gz cpython-6588712bf02e8e9ee374c92e2c1333f2f0029dc2.tar.bz2 |
Merge 3.5 (issue #27223)
Diffstat (limited to 'Lib/asyncio/selector_events.py')
-rw-r--r-- | Lib/asyncio/selector_events.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py index 7ae532d..6650da2 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -569,6 +569,7 @@ class _SelectorTransport(transports._FlowControlMixin, self._loop.remove_reader(self._sock_fd) if not self._buffer: self._conn_lost += 1 + self._loop.remove_writer(self._sock_fd) self._loop.call_soon(self._call_connection_lost, None) # On Python 3.3 and older, objects with a destructor part of a reference @@ -663,6 +664,8 @@ class _SelectorSocketTransport(_SelectorTransport): logger.debug("%r resumes reading", self) def _read_ready(self): + if self._conn_lost: + return try: data = self._sock.recv(self.max_size) except (BlockingIOError, InterruptedError): @@ -722,6 +725,8 @@ class _SelectorSocketTransport(_SelectorTransport): def _write_ready(self): assert self._buffer, 'Data should not be empty' + if self._conn_lost: + return try: n = self._sock.send(self._buffer) except (BlockingIOError, InterruptedError): @@ -892,6 +897,8 @@ class _SelectorSslTransport(_SelectorTransport): logger.debug("%r resumes reading", self) def _read_ready(self): + if self._conn_lost: + return if self._write_wants_read: self._write_wants_read = False self._write_ready() @@ -924,6 +931,8 @@ class _SelectorSslTransport(_SelectorTransport): self.close() def _write_ready(self): + if self._conn_lost: + return if self._read_wants_write: self._read_wants_write = False self._read_ready() @@ -1001,6 +1010,8 @@ class _SelectorDatagramTransport(_SelectorTransport): return sum(len(data) for data, _ in self._buffer) def _read_ready(self): + if self._conn_lost: + return try: data, addr = self._sock.recvfrom(self.max_size) except (BlockingIOError, InterruptedError): |