diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-07-04 21:27:10 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-07-04 21:27:10 +0000 |
commit | 5f0c7792afb3bd08c2b926897a504814891ce8b4 (patch) | |
tree | 3d00f89c5aca716fcedc350db77fd63417001899 /pym/_emerge/__init__.py | |
parent | 104c13c1c63fb822cbf0b1dd1e8e5c77478a56a2 (diff) | |
download | portage-5f0c7792afb3bd08c2b926897a504814891ce8b4.tar.gz portage-5f0c7792afb3bd08c2b926897a504814891ce8b4.tar.bz2 portage-5f0c7792afb3bd08c2b926897a504814891ce8b4.zip |
Add a PollConstants class to serve as a layer of indirection for accessing
select.POLL* attributes which do not exist on interix. Thanks to grobian
for reporting.
svn path=/main/trunk/; revision=10930
Diffstat (limited to 'pym/_emerge/__init__.py')
-rw-r--r-- | pym/_emerge/__init__.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 72413191b..f270cc622 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -1575,7 +1575,7 @@ class SpawnProcess(SubProcess): os.close(slave_fd) files.process = os.fdopen(master_fd, 'r') self.reg_id = self.scheduler.register(files.process.fileno(), - select.POLLIN, self._output_handler) + PollConstants.POLLIN, self._output_handler) self.registered = True def _output_handler(self, fd, event): @@ -1974,7 +1974,7 @@ class EbuildPhase(SubProcess): os.close(slave_fd) files.ebuild = os.fdopen(master_fd, 'r') self.reg_id = self.scheduler.register(files.ebuild.fileno(), - select.POLLIN, output_handler) + PollConstants.POLLIN, output_handler) self.registered = True def _output_handler(self, fd, event): @@ -7019,7 +7019,21 @@ class PackageCounters(object): (self.blocks - self.blocks_satisfied)) return "".join(myoutput) -class PollSelectAdapter(object): +class PollConstants(object): + + """ + Provides POLL* constants that are equivalent to those from the + select module, for use by PollSelectAdapter. + """ + + names = ("POLLIN", "POLLPRI", "POLLOUT", "POLLERR", "POLLHUP", "POLLNVAL") + v = 1 + for k in names: + locals()[k] = getattr(select, k, v) + v *= 2 + del k, v + +class PollSelectAdapter(PollConstants): """ Use select to emulate a poll object, for @@ -7032,14 +7046,15 @@ class PollSelectAdapter(object): def register(self, fd, *args): """ - Only select.POLLIN is currently supported! + Only POLLIN is currently supported! """ if len(args) > 1: raise TypeError( "register expected at most 2 arguments, got " + \ repr(1 + len(args))) - eventmask = select.POLLIN | select.POLLPRI | select.POLLOUT + eventmask = PollConstants.POLLIN | \ + PollConstants.POLLPRI | PollConstants.POLLOUT if args: eventmask = args[0] @@ -7071,7 +7086,7 @@ class PollSelectAdapter(object): select_events = select.select(*select_args) poll_events = [] for fd in select_events[0]: - poll_events.append((fd, select.POLLIN)) + poll_events.append((fd, PollConstants.POLLIN)) return poll_events class SequentialTaskQueue(SlotObject): |