summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/selector_events.py
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2016-06-11 15:19:47 (GMT)
committerYury Selivanov <yury@magic.io>2016-06-11 15:19:47 (GMT)
commitca2e0a48cf0dd663ba7457dc6bce60988cdfd56c (patch)
treed3c4e2a92bbfb1b9c0ca2409464a3fadf067ae02 /Lib/asyncio/selector_events.py
parent8ace13be39d4ac712d79cede4f3a66fab00c90f6 (diff)
downloadcpython-ca2e0a48cf0dd663ba7457dc6bce60988cdfd56c.zip
cpython-ca2e0a48cf0dd663ba7457dc6bce60988cdfd56c.tar.gz
cpython-ca2e0a48cf0dd663ba7457dc6bce60988cdfd56c.tar.bz2
Issue #27223: aio: Fix _read_ready and _write_ready to respect _conn_lost.
Patch by Ɓukasz Langa.
Diffstat (limited to 'Lib/asyncio/selector_events.py')
-rw-r--r--Lib/asyncio/selector_events.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index fb7ab21..9564d01 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
@@ -662,6 +663,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):
@@ -721,6 +724,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):
@@ -891,6 +896,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()
@@ -923,6 +930,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()
@@ -1000,6 +1009,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):