Esempio n. 1
0
 def test_FDTimer_absolute(self):
     t = itimer.FDTimer(itimer.CLOCK_MONOTONIC)
     start = time.time()
     t.settime(itimer.gettime(itimer.CLOCK_MONOTONIC) + 5.0, 0.0, absolute=True)
     print(t.read())
     t.close()
     self.assertAlmostEqual(time.time() - start, 5.0, places=2)
Esempio n. 2
0
 def test_FDTimer_absolute(self):
     t = itimer.FDTimer(itimer.CLOCK_MONOTONIC)
     start = time.time()
     t.settime(itimer.gettime(itimer.CLOCK_MONOTONIC)+5.0, 0.0, absolute=True)
     print(t.read())
     t.close()
     self.assertAlmostEqual(time.time()-start, 5.0, places=2)
Esempio n. 3
0
 def add_task(self, callback, period=0.0, delay=0.0, duration=None, callback_args=()):
     task = PeriodicTask(callback, period, delay, callback_args)
     self._poller.register(task)
     if duration:
         expire = gettime() + duration + delay
         heappush(self._expireq, (expire, task))
         self._duration_timer.settime(self._expireq[0][0], 0.0, absolute=True)
Esempio n. 4
0
 def add_task(self,
              callback,
              period=0.0,
              delay=0.0,
              duration=None,
              callback_args=()):
     task = PeriodicTask(callback, period, delay, callback_args)
     self._poller.register(task)
     if duration:
         expire = gettime() + duration + delay
         heappush(self._expireq, (expire, task))
         self._duration_timer.settime(self._expireq[0][0],
                                      0.0,
                                      absolute=True)