diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-06-19 12:59:32 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-06-19 12:59:32 +0200 |
commit | 6ef1202eb9de1a402a3fe14df05d90ae93e78d3e (patch) | |
tree | 532ee2cd56532a64f9c26b916b5f55daf5ce00e2 | |
parent | 9ec15176bca8e5836c540c9cd84e209bed7a8a73 (diff) | |
parent | 54c4b8e5c1e0fd11235ab0d5c848e5355293c964 (diff) | |
download | cpython-git-6ef1202eb9de1a402a3fe14df05d90ae93e78d3e.tar.gz |
(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.
-rw-r--r-- | 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 index 1f8e5c8bf6..854e815138 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -83,10 +83,15 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop): 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 |