Handle OSError from os.read and loop if needed.
authorZac Medico <zmedico@gentoo.org>
Fri, 2 Dec 2011 06:14:13 +0000 (22:14 -0800)
committerZac Medico <zmedico@gentoo.org>
Fri, 2 Dec 2011 06:14:13 +0000 (22:14 -0800)
Looping fixes EbuildMetadataPhase failures for ebuilds that produce
more than 4096 bytes of metadata, broken since commit
b432a1b3051d91546649e8f3190675767461d8e8.

pym/_emerge/AsynchronousLock.py
pym/_emerge/EbuildMetadataPhase.py
pym/_emerge/PipeReader.py

index 39e36c88043311c1c64e60c13eab785886017dab..9d0545beba04d82433c9d6ab2f0bc2493ac3364d 100644 (file)
@@ -138,7 +138,7 @@ class _LockThread(AbstractPollTask):
                if event & PollConstants.POLLIN:
                        try:
                                buf = os.read(self._files['pipe_read'], self._bufsize)
-                       except IOError as e:
+                       except OSError as e:
                                if e.errno not in (errno.EAGAIN,):
                                        raise
                if buf:
@@ -274,7 +274,7 @@ class _LockProcess(AbstractPollTask):
                if event & PollConstants.POLLIN:
                        try:
                                buf = os.read(self._files['pipe_in'], self._bufsize)
-                       except IOError as e:
+                       except OSError as e:
                                if e.errno not in (errno.EAGAIN,):
                                        raise
                if buf:
index e068e8f249101e5cb06c6dc27012950ce1bc098b..d4f5bc009ddfa61d74f48010e9b9397a7a3272b5 100644 (file)
@@ -112,16 +112,19 @@ class EbuildMetadataPhase(SubProcess):
        def _output_handler(self, fd, event):
 
                if event & PollConstants.POLLIN:
-                       try:
-                               self._raw_metadata.append(
-                                       os.read(self._files.ebuild, self._bufsize))
-                       except IOError as e:
-                               if e.errno not in (errno.EAGAIN,):
-                                       raise
-                       else:
-                               if not self._raw_metadata[-1]:
-                                       self._unregister()
-                                       self.wait()
+                       while True:
+                               try:
+                                       self._raw_metadata.append(
+                                               os.read(self._files.ebuild, self._bufsize))
+                               except OSError as e:
+                                       if e.errno not in (errno.EAGAIN,):
+                                               raise
+                                       break
+                               else:
+                                       if not self._raw_metadata[-1]:
+                                               self._unregister()
+                                               self.wait()
+                                               break
 
                self._unregister_if_appropriate(event)
 
index 67144c39362c4655424c1bf56b17c1356a57df39..af8cfdd4e70b91d46391242b5a8a3e0386b0e4dc 100644 (file)
@@ -59,18 +59,21 @@ class PipeReader(AbstractPollTask):
 
                if event & PollConstants.POLLIN:
 
-                       data = None
-                       try:
-                               data = os.read(fd, self._bufsize)
-                       except IOError as e:
-                               if e.errno not in (errno.EAGAIN,):
-                                       raise
-                       else:
-                               if data:
-                                       self._read_data.append(data)
+                       while True:
+                               data = None
+                               try:
+                                       data = os.read(fd, self._bufsize)
+                               except OSError as e:
+                                       if e.errno not in (errno.EAGAIN,):
+                                               raise
+                                       break
                                else:
-                                       self._unregister()
-                                       self.wait()
+                                       if data:
+                                               self._read_data.append(data)
+                                       else:
+                                               self._unregister()
+                                               self.wait()
+                                               break
 
                self._unregister_if_appropriate(event)