Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 54c4b8e

Browse files
committed
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.
1 parent 6bfd854 commit 54c4b8e

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

Lib/asyncio/selector_events.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,15 @@ def _make_self_pipe(self):
8383
self.add_reader(self._ssock.fileno(), self._read_from_self)
8484

8585
def _read_from_self(self):
86-
try:
87-
self._ssock.recv(1)
88-
except (BlockingIOError, InterruptedError):
89-
pass
86+
while True:
87+
try:
88+
data = self._ssock.recv(4096)
89+
if not data:
90+
break
91+
except InterruptedError:
92+
continue
93+
except BlockingIOError:
94+
break
9095

9196
def _write_to_self(self):
9297
# This may be called from a different thread, possibly after

0 commit comments

Comments
 (0)