예제 #1
0
def start(period=1.0, *args):
    global should_run
    if not should_run:
        should_run = 1
        first_time = math.floor(time.time()) + period
        scheduler.at(first_time, absolute_callback, (period,first_time,))
        scheduler.after(first_time-time.time(),
                        relative_callback, (period,first_time,))
    return
예제 #2
0
def absolute_callback(period,*args):
    global should_run
    this_time = time.time()
    if should_run:
        next_time = math.floor(time.time()) + period
        scheduler.at(next_time,
                     absolute_callback, (period,next_time,))
        print 'A: %s %s' % (this_time, args)
    else:
        print 'A: %s %s - STOPPED' % (this_time, args)
    return
예제 #3
0
 def set_timeout(self, timeout):
     super(FaultEvent, self).set_timeout(timeout)
     self.timeoutevent = FaultTimedOut(self, self.closetime, self.source,
                                       None, self.origin, None)
     self.scheduled_timeout = scheduler.at(self.closetime,
                                           self.handle_event,
                                           (self.timeoutevent, ))
예제 #4
0
 def go(self):
     if self._scheduled is not None and self.scheduled_time() > time.time():
         # The drifting clock has done us in...
         self._scheduled = scheduler.at(self.scheduled_time(), self.go, ())
         return
     thread = threading.Thread(name=self.log.name,
                               target=self.collect,args=())
     thread.start()
예제 #5
0
파일: adapters.py 프로젝트: mcruse/monotone
 def override(self, value, seconds = None, *clearing_value):
     if len(clearing_value):
         self.set_clearing_value(clearing_value[0])
     self.__state_lock.acquire()
     try:
         self.__override = override = UUID()
         self.__overridden_at = time.time()
         self.__clears_at = None
         self.node.set(value)
         self.active_overrides.setdefault(self.node.url, self)
         if seconds is not None:
             self.__clears_at = self.__overridden_at + seconds
             scheduler.at(self.__clears_at, self.clear_override, (override,))
     finally:
         self.__state_lock.release()
     self.__notify_if_changed()
     return override
예제 #6
0
 def override(self, value, seconds=None, *clearing_value):
     if len(clearing_value):
         self.set_clearing_value(clearing_value[0])
     self.__state_lock.acquire()
     try:
         self.__override = override = UUID()
         self.__overridden_at = time.time()
         self.__clears_at = None
         self.node.set(value)
         self.active_overrides.setdefault(self.node.url, self)
         if seconds is not None:
             self.__clears_at = self.__overridden_at + seconds
             scheduler.at(self.__clears_at, self.clear_override,
                          (override, ))
     finally:
         self.__state_lock.release()
     self.__notify_if_changed()
     return override
예제 #7
0
 def schedule_subscription(self, subscription, timestamp):
     self.scheduling_lock.acquire()
     try:
         schedulegroup = self.execution_groups.get(timestamp)
         if schedulegroup is None:
             schedulegroup = SubscriptionGroup(self, timestamp)
             self.execution_groups[timestamp] = schedulegroup
             schedulegroup.scheduled = scheduler.at(timestamp,
                                                    schedulegroup.execute)
         schedentry = schedulegroup.add_subscription(subscription)
     finally:
         self.scheduling_lock.release()
     return schedentry
예제 #8
0
파일: monitor.py 프로젝트: mcruse/monotone
 def schedule_subscription(self, subscription, timestamp):
     self.scheduling_lock.acquire()
     try:
         schedulegroup = self.execution_groups.get(timestamp)
         if schedulegroup is None:
             schedulegroup = SubscriptionGroup(self, timestamp)
             self.execution_groups[timestamp] = schedulegroup
             schedulegroup.scheduled = scheduler.at(
                 timestamp, schedulegroup.execute)
         schedentry = schedulegroup.add_subscription(subscription)
     finally:
         self.scheduling_lock.release()
     return schedentry
예제 #9
0
 def _schedule(self):
     next = self.next_time()
     self._scheduled = scheduler.at(next, self.go, (next,))
예제 #10
0
파일: cache.py 프로젝트: mcruse/monotone
 def setup_subscr_timer(self):
     self._scan_scheduled = scheduler.at(self.next_scan_time(), self.scan, ())
예제 #11
0
 def _schedule(self):
     if self.period == 0:
         self._scheduled = None
         return
     self._scheduled = scheduler.at(self.next_scheduled_time(),self.go,())
예제 #12
0
 def _schedule_toggle(self):
     when = time.time() + self.device.toggle_period
     self._scheduled = scheduler.at(when, self._toggle_state, ())
     return
예제 #13
0
파일: point.py 프로젝트: mcruse/monotone
 def _schedule_refresh(self):
     scheduler.at(self._next_time(), self._refresh)
예제 #14
0
 def setup_subscr_timer(self):
     self._scan_scheduled = scheduler.at(self.next_scan_time(), self.scan,
                                         ())
예제 #15
0
파일: interim.py 프로젝트: mcruse/monotone
 def set_timeout(self, timeout):
     super(FaultEvent, self).set_timeout(timeout)
     self.timeoutevent = FaultTimedOut(
         self, self.closetime, self.source, None, self.origin, None)
     self.scheduled_timeout = scheduler.at(
         self.closetime, self.handle_event, (self.timeoutevent,))
예제 #16
0
 def _schedule(self):
     next = self.next_time()
     self._scheduled = scheduler.at(next, self.go, (next, ))
예제 #17
0
 def _schedule_refresh(self):
     scheduler.at(self._next_time(), self._refresh)