summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/PipeReader.py30
1 files changed, 11 insertions, 19 deletions
diff --git a/pym/_emerge/PipeReader.py b/pym/_emerge/PipeReader.py
index 888c60963..67144c393 100644
--- a/pym/_emerge/PipeReader.py
+++ b/pym/_emerge/PipeReader.py
@@ -4,8 +4,8 @@
from portage import os
from _emerge.AbstractPollTask import AbstractPollTask
from _emerge.PollConstants import PollConstants
+import errno
import fcntl
-import array
class PipeReader(AbstractPollTask):
@@ -59,26 +59,18 @@ class PipeReader(AbstractPollTask):
if event & PollConstants.POLLIN:
- for f in self.input_files.values():
- if fd == f.fileno():
- break
-
- buf = array.array('B')
+ data = None
try:
- buf.fromfile(f, self._bufsize)
- except (EOFError, IOError):
- pass
-
- if buf:
- try:
- # Python >=3.2
- data = buf.tobytes()
- except AttributeError:
- data = buf.tostring()
- self._read_data.append(data)
+ data = os.read(fd, self._bufsize)
+ except IOError as e:
+ if e.errno not in (errno.EAGAIN,):
+ raise
else:
- self._unregister()
- self.wait()
+ if data:
+ self._read_data.append(data)
+ else:
+ self._unregister()
+ self.wait()
self._unregister_if_appropriate(event)