[Python-checkins] cpython (merge 3.4 -> default): (Merge 3.4) Closes #21595: asyncio.BaseSelectorEventLoop._read_from_self() now

victor.stinner python-checkins at python.org
Thu Jun 19 13:00:18 CEST 2014


http://hg.python.org/cpython/rev/513eea89b80a
changeset: 91273:513eea89b80a
parent: 91271:b57cdb945bf9
parent: 91272:46c251118799
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu Jun 19 12:59:32 2014 +0200
summary:
 (Merge 3.4) Closes #21595: asyncio.BaseSelectorEventLoop._read_from_self() now
reads all available bytes from the "self pipe", not only a single byte. This
change reduces the risk of having the pipe full and so getting the innocuous
"BlockingIOError: [Errno 11] Resource temporarily unavailable" message.
files:
 Lib/asyncio/selector_events.py | 13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -83,10 +83,15 @@
 self.add_reader(self._ssock.fileno(), self._read_from_self)
 
 def _read_from_self(self):
- try:
- self._ssock.recv(1)
- except (BlockingIOError, InterruptedError):
- pass
+ while True:
+ try:
+ data = self._ssock.recv(4096)
+ if not data:
+ break
+ except InterruptedError:
+ continue
+ except BlockingIOError:
+ break
 
 def _write_to_self(self):
 # This may be called from a different thread, possibly after
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /