Exemplo n.º 1
0
 def await_unlocked(self):
     while True:
         timeout = (
             fractionalSeconds(self._unlock_timestamp - datetime.utcnow())
             if self._unlock_timestamp
             else INDEFINITELY
         )
         if timeout is not None and timeout <= 0:
             return
         with self._unlocked:
             self._unlocked.wait(timeout)
Exemplo n.º 2
0
 def run(self):
   with self._sleepingTasks:
     while self.active:
       while not self._pq:
         self._sleepingTasks.wait(99999)
       sleep_time = self._pq[0][0] - datetime.utcnow()
       if sleep_time > timedelta(0):
         self._sleepingTasks.wait(fractionalSeconds(sleep_time))
       else:
         (time, task, args, kwargs) = heappop(self._pq)
         callback = kwargs.pop('callback', None)
         future = self.submit(task, *args, **kwargs)
         if callback:
           future.add_done_callback(callback)