From: Zac Medico Date: Fri, 2 Dec 2011 06:14:13 +0000 (-0800) Subject: Handle OSError from os.read and loop if needed. X-Git-Tag: v2.2.0_alpha80~72 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c6c71eefb9532af0d4505de70e58f45ad8e8fe0a;p=portage.git Handle OSError from os.read and loop if needed. Looping fixes EbuildMetadataPhase failures for ebuilds that produce more than 4096 bytes of metadata, broken since commit b432a1b3051d91546649e8f3190675767461d8e8. --- diff --git a/pym/_emerge/AsynchronousLock.py b/pym/_emerge/AsynchronousLock.py index 39e36c880..9d0545beb 100644 --- a/pym/_emerge/AsynchronousLock.py +++ b/pym/_emerge/AsynchronousLock.py @@ -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: diff --git a/pym/_emerge/EbuildMetadataPhase.py b/pym/_emerge/EbuildMetadataPhase.py index e068e8f24..d4f5bc009 100644 --- a/pym/_emerge/EbuildMetadataPhase.py +++ b/pym/_emerge/EbuildMetadataPhase.py @@ -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) diff --git a/pym/_emerge/PipeReader.py b/pym/_emerge/PipeReader.py index 67144c393..af8cfdd4e 100644 --- a/pym/_emerge/PipeReader.py +++ b/pym/_emerge/PipeReader.py @@ -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)