from portage import _encodings
from portage import _unicode_decode
from portage import _unicode_encode
+import errno
import fcntl
import io
if fd == sys.stderr.fileno():
sys.stderr.flush()
- fd_pipes_orig = fd_pipes.copy()
self._files = self._files_dict()
files = self._files
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
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)