def stop(self): if self.sched_id: scheduler.cancel(self.sched_id) self.sched_id = None self.set('idle') self.setIdle() self.isStarted = 0
def export(self, alarm, attempt=0): self._lock.acquire() try: if (not self._started): self._alarm.append(alarm) # No need to set scheduler here; start() will call # export_waiting_alarm()... return # Even if this node is already started, do not attempt to # export alarm unless the linked log node and its collector # object are extant and started: if (self.log.collector is None): self._alarm.append(alarm) if (self._waiting_alarm_sid is None): # if we're not already scheduled, do it: # Need to wait long enough for log.start() to finish creating # and starting collector. ***GUESS*** 10.0 sec. Symptom of not # waiting long enough: ENotStarted error raised below: self._waiting_alarm_sid = scheduler.after( 10.0, self.export_waiting_alarm, ()) return finally: self._lock.release() self.log.collector.pause() try: try: if not self.log.collector.running: raise ENotStarted('Collector not started yet.') entry = self.log.collector.get_entry() entry[self.ts_position] = time.time() # Stamp source, if target log columns support it: if isinstance(self.trigger_node_url_posn, int): entry[self.trigger_node_url_posn] = as_node_url( alarm.source) if isinstance(self.trigger_node_msg_posn, int): entry[self.trigger_node_msg_posn] = str(alarm) self.log.add_entry(entry) t = time.time() for child in self.log.get_child('exporters').children_nodes(): child.go(t) # starts threads for long ops except: msglog.exception() if attempt > alarm.source.send_retries: msglog.log('broadway', msglog.types.WARN, 'Export of alarm failed, aborting send.') raise MpxException('Log and export failed.') else: msglog.log('broadway', msglog.types.WARN, 'Log on alarm failed, delaying 1.0 sec.') self._lock.acquire() try: if self._scheduled != None: scheduler.cancel(self._scheduled) self._scheduled = scheduler.after( 1, self.export, (alarm, attempt + 1)) finally: self._lock.release() finally: self.log.collector.play() return
def stop(self): self._running = 0 CompositeNode.stop(self) if not self._sid is None: scheduler.cancel(self._sid) self._sid = None return
def stop( self ): if self.sched_id: scheduler.cancel( self.sched_id ) self.sched_id = None self.set( 'idle' ) self.setIdle() self.isStarted = 0
def export(self, alarm, attempt=0): self._lock.acquire() try: if (not self._started): self._alarm.append(alarm) # No need to set scheduler here; start() will call # export_waiting_alarm()... return # Even if this node is already started, do not attempt to # export alarm unless the linked log node and its collector # object are extant and started: if (self.log.collector is None): self._alarm.append(alarm) if (self._waiting_alarm_sid is None): # if we're not already scheduled, do it: # Need to wait long enough for log.start() to finish creating # and starting collector. ***GUESS*** 10.0 sec. Symptom of not # waiting long enough: ENotStarted error raised below: self._waiting_alarm_sid = scheduler.after(10.0, self.export_waiting_alarm, ()) return finally: self._lock.release() self.log.collector.pause() try: try: if not self.log.collector.running: raise ENotStarted('Collector not started yet.') entry = self.log.collector.get_entry() entry[self.ts_position] = time.time() # Stamp source, if target log columns support it: if isinstance(self.trigger_node_url_posn, int): entry[self.trigger_node_url_posn] = as_node_url(alarm.source) if isinstance(self.trigger_node_msg_posn, int): entry[self.trigger_node_msg_posn] = str(alarm) self.log.add_entry(entry) t = time.time() for child in self.log.get_child('exporters').children_nodes(): child.go(t) # starts threads for long ops except: msglog.exception() if attempt > alarm.source.send_retries: msglog.log('broadway',msglog.types.WARN, 'Export of alarm failed, aborting send.') raise MpxException('Log and export failed.') else: msglog.log('broadway',msglog.types.WARN, 'Log on alarm failed, delaying 1.0 sec.') self._lock.acquire() try: if self._scheduled != None: scheduler.cancel(self._scheduled) self._scheduled = scheduler.after(1,self.export, (alarm,attempt+1)) finally: self._lock.release() finally: self.log.collector.play() return
def set(self, stateName): _stateName = stateName.lower() if self.stateDict.has_key(_stateName): self.stateName = _stateName self.stateSetFunction = self.stateDict[_stateName] if self.isStarted and self.sched_id: scheduler.cancel(self.sched_id) self._schedule() else: msg = "valid states are one of %s" % repr(self.stateDict.keys()) raise EInvalidValue('state name', stateName, msg)
def set( self, stateName ): _stateName = stateName.lower() if self.stateDict.has_key( _stateName ): self.stateName = _stateName self.stateSetFunction = self.stateDict[_stateName] if self.isStarted and self.sched_id: scheduler.cancel( self.sched_id ) self._schedule() else: msg = "valid states are one of %s" % repr( self.stateDict.keys() ) raise EInvalidValue( 'state name', stateName, msg )
def notify(self, n=1): if not self._lock.locked(): raise AssertionError('wait called on un-acquire()d lock') release_count = 0 locks = self._locks for lock in locks: if lock.get_id(): scheduler.cancel(lock.get_id()) if not lock.acquire(0): release_count += 1 lock.release() try: self._locks.remove(lock) except ValueError: pass if release_count == n: return
def stop(self): Client.stop(self) if self.sid: scheduler.cancel(self.sid)
def stop( self ): CompositeNode.stop( self ) if self.sched_id: scheduler.cancel( self.sched_id ) self.sched_id = None self.isStarted = 0