Esempio n. 1
0
 def func2(n, mp_queue):
     if mp_queue is not None:
         timer.configure(timer.LocalTimerClient(mp_queue))
     if n > 0:
         with timer.expires(after=0.1):
             func2(n - 1, None)
             time.sleep(0.2)
Esempio n. 2
0
        def test_client_interaction(self):
            # no timer client configured but one passed in explicitly
            # no exception expected
            timer_client = timer.LocalTimerClient(self.mp_queue)
            timer_client.acquire = mock.MagicMock(wraps=timer_client.acquire)
            timer_client.release = mock.MagicMock(wraps=timer_client.release)
            with timer.expires(after=1, scope="test", client=timer_client):
                pass

            timer_client.acquire.assert_called_once_with("test", mock.ANY)
            timer_client.release.assert_called_once_with("test")
Esempio n. 3
0
        def _run(mp_queue, timeout, duration):
            client = timer.LocalTimerClient(mp_queue)
            timer.configure(client)

            with timer.expires(after=timeout):
                time.sleep(duration)
Esempio n. 4
0
 def func2(n):
     if n > 0:
         with timer.expires(after=0.1):
             func2(n - 1)
             time.sleep(0.2)
Esempio n. 5
0
 def test_happy_path(self):
     timer.configure(timer.LocalTimerClient(self.mp_queue))
     with timer.expires(after=0.5):
         time.sleep(0.1)
Esempio n. 6
0
 def test_no_client(self):
     # no timer client configured; exception expected
     timer.configure(None)
     with self.assertRaises(RuntimeError):
         with timer.expires(after=1):
             pass
Esempio n. 7
0
 def test_exception_propagation(self):
     with self.assertRaises(Exception, msg="foobar"):
         with timer.expires(after=1):
             raise Exception("foobar")
Esempio n. 8
0
def _stuck_function(rank, mp_queue):
    timer.configure(timer.LocalTimerClient(mp_queue))
    with timer.expires(after=1):
        time.sleep(5)