1. Stefano Rivera
  2. pypy

Commits

Stefano Rivera  committed ca15c5b

Catch EAGAIN in BufferingInputStream.readline()

  • Participants
  • Parent commits 71219b3
  • Branches default

Comments (0)

Files changed (1)

File pypy/rlib/streamio.py

View file
  • Ignore whitespace
             return result
         temp = self.buf[start:]
         # read one buffer and most of the time a new line will be found
-        self.buf = self.do_read(self.bufsize)
+        try:
+            self.buf = self.do_read(self.bufsize)
+        except OSError, o:
+            if o.errno != errno.EAGAIN:
+                raise
+            if not temp:
+                raise
+            self.buf = ''
         i = self.buf.find("\n")
         if i >= 0: # new line found
             i += 1
         # need to keep getting data until we find a new line
         chunks = [temp, self.buf]
         while 1:
-            self.buf = self.do_read(self.bufsize)
+            try:
+                self.buf = self.do_read(self.bufsize)
+            except OSError, o:
+                if o.errno != errno.EAGAIN:
+                    raise
+                if chunks == ['', '']:
+                    raise
+                self.buf = ''
             if not self.buf:
                 self.pos = 0
                 break