Esempio n. 1
0
 def run(self, context):
     while context.authorized:
         self.sync_inventory.run(context)
         if self.sync_update.run(context):
             # Update available
             return
         timeutil.sleep(context.update_timer, context.inventory_timer)
 def test_is_it_time_sleep_full(self):
     timer = timeutil.IsItTime(self.INTERVAL)
     timer.is_it_time()
     start_time = time.time()
     timeutil.sleep(timer)
     end_time = time.time()
     assert (end_time - start_time - self.INTERVAL) <= self.DT
 def test_is_it_time_sleep_partial(self):
     timer = timeutil.IsItTime(self.INTERVAL)
     timer.is_it_time()
     start_time = time.time()
     time.sleep(timer.seconds_till_next() * 0.5)
     timeutil.sleep(timer)
     end_time = time.time()
     assert (end_time - start_time - self.INTERVAL) <= self.DT
 def test_is_it_time_sleep_full_shortest(self):
     timer = timeutil.IsItTime(self.INTERVAL)
     longer_timer = timeutil.IsItTime(self.INTERVAL * 2)
     timer.is_it_time()
     longer_timer.is_it_time()
     start_time = time.time()
     timeutil.sleep(longer_timer, timer)
     end_time = time.time()
     assert (end_time - start_time - self.INTERVAL) <= self.DT
Esempio n. 5
0
 def run(self, context):
     log.info("Idling...")
     timeutil.sleep(context.retry_timer)
     return True