summaryrefslogtreecommitdiffstats
path: root/pym/_emerge/AbstractPollTask.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-09-09 20:05:19 -0700
committerZac Medico <zmedico@gentoo.org>2010-09-09 20:05:19 -0700
commitc299f8d465efad80b17074e1791c20024760648c (patch)
tree5be85e7b02793d898d6e59af161a76bb622c65c8 /pym/_emerge/AbstractPollTask.py
parente23e4a36210056ff2d46831f79fa5aa410e0b377 (diff)
downloadportage-c299f8d465efad80b17074e1791c20024760648c.tar.gz
portage-c299f8d465efad80b17074e1791c20024760648c.tar.bz2
portage-c299f8d465efad80b17074e1791c20024760648c.zip
Split out a AbstractPollTask._read_buf() helper method.
Diffstat (limited to 'pym/_emerge/AbstractPollTask.py')
-rw-r--r--pym/_emerge/AbstractPollTask.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/pym/_emerge/AbstractPollTask.py b/pym/_emerge/AbstractPollTask.py
index 1feee15f6..833ee3b4c 100644
--- a/pym/_emerge/AbstractPollTask.py
+++ b/pym/_emerge/AbstractPollTask.py
@@ -1,6 +1,8 @@
-# Copyright 1999-2009 Gentoo Foundation
+# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+import array
+
from _emerge.AsynchronousTask import AsynchronousTask
from _emerge.PollConstants import PollConstants
class AbstractPollTask(AsynchronousTask):
@@ -13,6 +15,27 @@ class AbstractPollTask(AsynchronousTask):
_registered_events = PollConstants.POLLIN | PollConstants.POLLHUP | \
_exceptional_events
+ def _read_buf(self, f, event):
+ """
+ | POLLIN | RETURN
+ | BIT | VALUE
+ | ---------------------------------------------------
+ | 1 | Read self._bufsize into an instance of
+ | | array.array('B') and return it, ignoring
+ | | EOFError and IOError. An empty array
+ | | indicates EOF.
+ | ---------------------------------------------------
+ | 0 | None
+ """
+ buf = None
+ if event & PollConstants.POLLIN:
+ buf = array.array('B')
+ try:
+ buf.fromfile(f, self._bufsize)
+ except (EOFError, IOError):
+ pass
+ return buf
+
def _unregister(self):
raise NotImplementedError(self)