from portage.util import writemsg_level
from _emerge.AsynchronousTask import AsynchronousTask
-from _emerge.PollConstants import PollConstants
+
class AbstractPollTask(AsynchronousTask):
__slots__ = ("scheduler",) + \
("_registered",)
_bufsize = 4096
- _exceptional_events = PollConstants.POLLERR | PollConstants.POLLNVAL
- _registered_events = PollConstants.POLLIN | PollConstants.POLLHUP | \
- _exceptional_events
+
+ @property
+ def _exceptional_events(self):
+ return self.scheduler.IO_ERR | self.scheduler.IO_NVAL
+
+ @property
+ def _registered_events(self):
+ return self.scheduler.IO_IN | self.scheduler.IO_HUP | \
+ self._exceptional_events
def isAlive(self):
return bool(self._registered)
| 0 | None
"""
buf = None
- if event & PollConstants.POLLIN:
+ if event & self.scheduler.IO_IN:
buf = array.array('B')
try:
buf.fromfile(f, self._bufsize)
# bugs in all known versions of Python (including Python 2.7
# and Python 3.2).
buf = None
- if event & PollConstants.POLLIN:
+ if event & self.scheduler.IO_IN:
try:
buf = os.read(fd, self._bufsize)
except OSError as e:
self._log_poll_exception(event)
self._unregister()
self.cancel()
- elif event & PollConstants.POLLHUP:
+ elif event & self.scheduler.IO_HUP:
self._unregister()
self.wait()
from portage.util import writemsg_level
from _emerge.AbstractPollTask import AbstractPollTask
from _emerge.AsynchronousTask import AsynchronousTask
-from _emerge.PollConstants import PollConstants
from _emerge.SpawnProcess import SpawnProcess
class AsynchronousLock(AsynchronousTask):
fcntl.fcntl(f, fcntl.F_SETFL,
fcntl.fcntl(f, fcntl.F_GETFL) | os.O_NONBLOCK)
self._reg_id = self.scheduler.register(self._files['pipe_read'],
- PollConstants.POLLIN, self._output_handler)
+ self.scheduler.IO_IN, self._output_handler)
self._registered = True
threading_mod = threading
if self._force_dummy:
def _output_handler(self, f, event):
buf = None
- if event & PollConstants.POLLIN:
+ if event & self.scheduler.IO_IN:
try:
buf = os.read(self._files['pipe_read'], self._bufsize)
except OSError as e:
fcntl.fcntl(in_pr, fcntl.F_SETFL,
fcntl.fcntl(in_pr, fcntl.F_GETFL) | os.O_NONBLOCK)
self._reg_id = self.scheduler.register(in_pr,
- PollConstants.POLLIN, self._output_handler)
+ self.scheduler.IO_IN, self._output_handler)
self._registered = True
self._proc = SpawnProcess(
args=[portage._python_interpreter,
def _output_handler(self, f, event):
buf = None
- if event & PollConstants.POLLIN:
+ if event & self.scheduler.IO_IN:
try:
buf = os.read(self._files['pipe_in'], self._bufsize)
except OSError as e:
-# Copyright 2010-2011 Gentoo Foundation
+# Copyright 2010-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import errno
from portage.localization import _
from portage.util import writemsg_level
from _emerge.FifoIpcDaemon import FifoIpcDaemon
-from _emerge.PollConstants import PollConstants
class EbuildIpcDaemon(FifoIpcDaemon):
"""
def _input_handler(self, fd, event):
# Read the whole pickle in a single atomic read() call.
data = None
- if event & PollConstants.POLLIN:
+ if event & self.scheduler.IO_IN:
# For maximum portability, use os.read() here since
# array.fromfile() and file.read() are both known to
# erroneously return an empty string from this
-# Copyright 1999-2011 Gentoo Foundation
+# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from _emerge.SubProcess import SubProcess
-from _emerge.PollConstants import PollConstants
import sys
from portage.cache.mappings import slot_dict_class
import portage
def _output_handler(self, fd, event):
- if event & PollConstants.POLLIN:
+ if event & self.scheduler.IO_IN:
while True:
try:
self._raw_metadata.append(
class PollScheduler(object):
class _sched_iface_class(SlotObject):
- __slots__ = ("idle_add", "io_add_watch", "iteration",
+ __slots__ = ("IO_ERR", "IO_HUP", "IO_IN", "IO_NVAL", "IO_OUT",
+ "IO_PRI", "idle_add", "io_add_watch", "iteration",
"output", "register", "run",
"source_remove", "timeout_add", "unregister")
self._background = False
self._event_loop = global_event_loop()
self.sched_iface = self._sched_iface_class(
+ IO_ERR=self._event_loop.IO_ERR,
+ IO_HUP=self._event_loop.IO_HUP,
+ IO_IN=self._event_loop.IO_IN,
+ IO_NVAL=self._event_loop.IO_NVAL,
+ IO_OUT=self._event_loop.IO_OUT,
+ IO_PRI=self._event_loop.IO_PRI,
idle_add=self._event_loop.idle_add,
io_add_watch=self._event_loop.io_add_watch,
iteration=self._event_loop.iteration,
fetch_iface = self._fetch_iface_class(log_file=self._fetch_log,
schedule=self._schedule_fetch)
self._sched_iface = self._iface_class(
+ IO_ERR=self._event_loop.IO_ERR,
+ IO_HUP=self._event_loop.IO_HUP,
+ IO_IN=self._event_loop.IO_IN,
+ IO_NVAL=self._event_loop.IO_NVAL,
+ IO_OUT=self._event_loop.IO_OUT,
+ IO_PRI=self._event_loop.IO_PRI,
fetch=fetch_iface, output=self._task_output,
idle_add=self._event_loop.idle_add,
io_add_watch=self._event_loop.io_add_watch,
-# Copyright 2010-2011 Gentoo Foundation
+# Copyright 2010-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import io
import portage
from portage import os, _unicode_decode
import portage.elog.messages
-from _emerge.PollConstants import PollConstants
from _emerge.SpawnProcess import SpawnProcess
class MergeProcess(SpawnProcess):
def _elog_output_handler(self, fd, event):
output = None
- if event & PollConstants.POLLIN:
+ if event & self.scheduler.IO_IN:
try:
output = os.read(fd, self._bufsize)
except OSError as e:
reporter = getattr(portage.elog.messages, funcname)
reporter(msg, phase=phase, key=key, out=out)
- if event & PollConstants.POLLHUP:
+ if event & self.scheduler.IO_HUP:
self.scheduler.unregister(self._elog_reg_id)
self._elog_reg_id = None
os.close(self._elog_reader_fd)