diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-06-19 10:59:15 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-06-19 10:59:15 (GMT) |
commit | 54c4b8e5c1e0fd11235ab0d5c848e5355293c964 (patch) | |
tree | 30832489bbac91a3f904a6eb952d4ceb07b56b6b | |
parent | 6bfd854ea81fecd82711ba2b6107718bab872635 (diff) | |
download | cpython-54c4b8e5c1e0fd11235ab0d5c848e5355293c964.zip cpython-54c4b8e5c1e0fd11235ab0d5c848e5355293c964.tar.gz cpython-54c4b8e5c1e0fd11235ab0d5c848e5355293c964.tar.bz2 |
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 1f8e5c8..854e815 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 |