diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-12-01 13:22:00 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-12-01 13:22:00 -0800 |
commit | b432a1b3051d91546649e8f3190675767461d8e8 (patch) | |
tree | d230c649aef246759ff2f1ea3f9b4ffded27ac4a | |
parent | b573f6f81c4500af9a4d08d58746d59c2b95f67c (diff) | |
download | portage-b432a1b3051d91546649e8f3190675767461d8e8.tar.gz portage-b432a1b3051d91546649e8f3190675767461d8e8.tar.bz2 portage-b432a1b3051d91546649e8f3190675767461d8e8.zip |
_emerge/EbuildMetadataPhase.py: use os.read()
There's no need for a file object, and file objects introduce
complexity that can lead to bugs as mentioned in bug 337465 comment 31,
so use os.read() directly on the file descriptor.
-rw-r--r-- | pym/_emerge/EbuildMetadataPhase.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/pym/_emerge/EbuildMetadataPhase.py b/pym/_emerge/EbuildMetadataPhase.py index 16948df76..e068e8f24 100644 --- a/pym/_emerge/EbuildMetadataPhase.py +++ b/pym/_emerge/EbuildMetadataPhase.py @@ -10,6 +10,7 @@ from portage import os from portage import _encodings from portage import _unicode_decode from portage import _unicode_encode +import errno import fcntl import io @@ -75,7 +76,6 @@ class EbuildMetadataPhase(SubProcess): if fd == sys.stderr.fileno(): sys.stderr.flush() - fd_pipes_orig = fd_pipes.copy() self._files = self._files_dict() files = self._files @@ -86,8 +86,8 @@ class EbuildMetadataPhase(SubProcess): fd_pipes[self._metadata_fd] = slave_fd self._raw_metadata = [] - files.ebuild = os.fdopen(master_fd, 'rb', 0) - self._reg_id = self.scheduler.register(files.ebuild.fileno(), + files.ebuild = master_fd + self._reg_id = self.scheduler.register(files.ebuild, self._registered_events, self._output_handler) self._registered = True @@ -112,10 +112,16 @@ class EbuildMetadataPhase(SubProcess): def _output_handler(self, fd, event): if event & PollConstants.POLLIN: - self._raw_metadata.append(self._files.ebuild.read()) - if not self._raw_metadata[-1]: - self._unregister() - self.wait() + 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() self._unregister_if_appropriate(event) |