borgend/scheduler.py

changeset 86
2fe66644c50d
parent 80
a409242121d5
child 87
a214d475aa28
equal deleted inserted replaced
85:56a000d15965 86:2fe66644c50d
3 # 3 #
4 # This module simply provide a way for other threads to until a given time 4 # This module simply provide a way for other threads to until a given time
5 # 5 #
6 6
7 import time 7 import time
8 import logging
8 from threading import Condition, Thread 9 from threading import Condition, Thread
9 10
10 from . import loggers
11 from . import dreamtime 11 from . import dreamtime
12 12
13 logger=loggers.get(__name__) 13 logger=logging.getLogger(__name__)
14 14
15 class QueuedEvent: 15 class QueuedEvent:
16 def __init__(self, cond, name=None): 16 def __init__(self, cond, name=None):
17 self.next=None 17 self.next=None
18 self.prev=None 18 self.prev=None
127 # Wait at most precision seconds, or until next event if it 127 # Wait at most precision seconds, or until next event if it
128 # comes earlier 128 # comes earlier
129 timeout=min(self.precision, self._list.when.realtime()-now) 129 timeout=min(self.precision, self._list.when.realtime()-now)
130 130
131 if not timeout or timeout>0: 131 if not timeout or timeout>0:
132 logger.debug("Scheduler waiting %d seconds" % (timeout or (-1))) 132 logger.debug("Scheduler waiting %s seconds" % str(timeout))
133 self._cond.wait(timeout) 133 self._cond.wait(timeout)
134 now = time.monotonic() 134 now = time.monotonic()
135 135
136 logger.debug("Scheduler timed out") 136 logger.debug("Scheduler timed out")
137 137

mercurial