]> granicus.if.org Git - python/commitdiff
Closes #21595: asyncio.BaseSelectorEventLoop._read_from_self() now reads all
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 19 Jun 2014 10:59:15 +0000 (12:59 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 19 Jun 2014 10:59:15 +0000 (12:59 +0200)
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.

Lib/asyncio/selector_events.py

index 1f8e5c8bf6d85626440a9506b0e72669a0ce1683..854e81513894f2b10d32025ba053da9442e7a861 100644 (file)
@@ -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