Exemplo n.º 1
0
 def test_nanosleep(self):
     global s
     signal.signal(signal.SIGALRM, catcher)
     start = s = time.time()
     try:
         signal.alarm(2)
         timers.nanosleep(10.0)
     finally:
         signal.signal(signal.SIGALRM, signal.SIG_DFL)
     self.assertAlmostEqual(time.time()-start, 10.0, places=2)
Exemplo n.º 2
0
 def test_timer_cset(self):
     global _t
     signal.signal(signal.SIGRTMIN, catcher)
     now = time.monotonic()
     try:
         _t.settime(now + 2.5, absolute=True)
         timers.nanosleep(1.0)
         print(_t.gettime())
         signal.pause()
         print(_t.gettime())
         _t.settime(0, absolute=True)
     finally:
         signal.signal(signal.SIGRTMIN, signal.SIG_DFL)
     self.assertAlmostEqual(time.monotonic()-now, 2.5, places=2)