PipeReader: use AbstractPollTask._read_buf()
authorZac Medico <zmedico@gentoo.org>
Fri, 16 Dec 2011 19:56:01 +0000 (11:56 -0800)
committerZac Medico <zmedico@gentoo.org>
Fri, 16 Dec 2011 19:56:01 +0000 (11:56 -0800)
pym/_emerge/PipeReader.py

index a465c2a28af4ffd4d600c0c79485c37c07579739..9fedbff6f4beb1df1fc08d7a1b7bcc9158ec3f89 100644 (file)
@@ -3,8 +3,6 @@
 
 from portage import os
 from _emerge.AbstractPollTask import AbstractPollTask
-from _emerge.PollConstants import PollConstants
-import errno
 import fcntl
 
 class PipeReader(AbstractPollTask):
@@ -57,30 +55,16 @@ class PipeReader(AbstractPollTask):
 
        def _output_handler(self, fd, event):
 
-               if event & PollConstants.POLLIN:
-
-                       while True:
-                               data = None
-                               try:
-                                       data = os.read(fd, self._bufsize)
-                               except OSError as e:
-                                       # EIO happens with pty on Linux after the
-                                       # slave end of the pty has been closed.
-                                       if e.errno == errno.EIO:
-                                               self._unregister()
-                                               self.wait()
-                                               break
-                                       elif e.errno == errno.EAGAIN:
-                                               break
-                                       else:
-                                               raise
-                               else:
-                                       if data:
-                                               self._read_data.append(data)
-                                       else:
-                                               self._unregister()
-                                               self.wait()
-                                               break
+               while True:
+                       data = self._read_buf(fd, event)
+                       if data is None:
+                               break
+                       if data:
+                               self._read_data.append(data)
+                       else:
+                               self._unregister()
+                               self.wait()
+                               break
 
                self._unregister_if_appropriate(event)