Example #1
0
    def __init__(self, pad, name, setActive, setInactive):
        """
        @type  pad:         L{gst.Pad}
        @type  name:        str
        @param setActive:   a callable that will be called when the pad is
                            considered active, taking the name of the monitor.
        @type  setActive:   callable
        @param setInactive: a callable that will be called when the pad is
                            considered inactive, taking the name of the
                            monitor.
        @type  setInactive: callable
        """
        self._last_data_time = -1  # system time in epoch secs of last reception
        self._pad = pad
        self.name = name
        self._active = False
        self._first = True
        self._running = True

        self._doSetActive = []
        self._doSetInactive = []
        self.addWatch(setActive, setInactive)

        # This dict sillyness is because python's dict operations are atomic
        # w.r.t. the GIL.
        self._probe_id = {}

        self.check_poller = Poller(self._probe_timeout,
                                   self.PAD_MONITOR_PROBE_INTERVAL,
                                   immediately=True)

        self.watch_poller = Poller(self._check_timeout,
                                   self.PAD_MONITOR_CHECK_INTERVAL)
Example #2
0
    def __init__(self, pad, name, setActive, setInactive, reconnectEater,
                 *args):
        PadMonitor.__init__(self, pad, name, setActive, setInactive)

        self._reconnectPoller = Poller(lambda: reconnectEater(*args),
                                       self.PAD_MONITOR_CHECK_INTERVAL,
                                       start=False)
Example #3
0
    def init(self):
        """
        A subclass should do as little as possible in its init method.
        In particular, it should not try to access resources.

        Failures during init are marshalled back to the manager through
        the worker's remote_create method, since there is no component state
        proxied to the manager yet at the time of init.
        """
        self.state = planet.WorkerJobState()

        self.name = self.config['name']

        self.state.set('pid', os.getpid())
        self.setMood(moods.waking)

        self.medium = None  # the medium connecting us to the manager's avatar

        self.uiState = componentui.WorkerComponentUIState()
        self.uiState.addKey('cpu-percent')
        self.uiState.addKey('start-time')
        self.uiState.addKey('current-time')
        self.uiState.addKey('virtual-size')
        self.uiState.addKey('total-memory')
        self.uiState.addKey('num-cpus')
        self.uiState.addKey('flu-debug')
        self.uiState.addKey('properties')

        self.uiState.addHook(self)

        self.plugs = {}

        self._happyWaits = []

        # Start the cpu-usage updating.
        self._lastTime = time.time()
        self._lastClock = time.clock()
        self._cpuPoller = Poller(self._pollCPU, 5, start=False)
        self._memoryPoller = Poller(self._pollMemory, 60, start=False)
        self._cpuPollerDC = None
        self._memoryPollerDC = None
        self._shutdownHook = None
Example #4
0
    def start(self, component):
        self._rrdpoller = None

        self._component = component

        if not self._hasImport():
            return

        properties = self.args['properties']
        self._clientsPath = properties['clients-connected-file']
        self._bytesPath = properties['bytes-transferred-file']
        self._stepSize = properties.get('step-size', _DEFAULT_STEP_SIZE)
        self._RRDPaths = self._getRRDPaths()
        # call to update_rrd with a poll interval
        timeout = properties.get('poll-interval', _DEFAULT_POLL_INTERVAL)
        self._rrdpoller = Poller(self._updateRRD, timeout)