Author: Amaury Forgeot d'Arc <[email protected]>
Branch: 
Changeset: r57311:f89a2c5b6a28
Date: 2012-09-13 01:02 +0200
http://bitbucket.org/pypy/pypy/changeset/f89a2c5b6a28/

Log:    Retry file.read() and file.write() when they are interrupted by a
        signal.

diff --git a/pypy/rlib/streamio.py b/pypy/rlib/streamio.py
--- a/pypy/rlib/streamio.py
+++ b/pypy/rlib/streamio.py
@@ -295,12 +295,23 @@
 
     def read(self, n):
         assert isinstance(n, int)
-        return os.read(self.fd, n)
+        while True:
+            try:
+                return os.read(self.fd, n)
+            except OSError, e:
+                if e.errno != errno.EINTR:
+                    raise
+                # else try again
 
     def write(self, data):
         while data:
-            n = os.write(self.fd, data)
-            data = data[n:]
+            try:
+                n = os.write(self.fd, data)
+            except OSError, e:
+                if e.errno != errno.EINTR:
+                    raise
+            else:
+                data = data[n:]
 
     def close(self):
         os.close(self.fd)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to