Пример #1
0
 def check_timed_out(self, event, myproc, proc_finished_flag, queue):
     X = object()
     assert with_timeout(DELAY, event.wait, timeout_value=X) is X
     assert with_timeout(DELAY, queue.wait, timeout_value=X) is X
     assert with_timeout(DELAY, proc.waitall, [myproc],
                         timeout_value=X) is X
     assert proc_finished_flag == [], proc_finished_flag
Пример #2
0
 def test_pause_producing(self):
     self.conn.pauseProducing()
     self.conn.write('hi\r\n')
     result = with_timeout(DELAY * 10,
                           self.conn.read,
                           timeout_value='timed out')
     self.assertEqual('timed out', result)
Пример #3
0
 def test_pauseresume_producing(self):
     self.conn.pauseProducing()
     call_after(DELAY * 5, self.conn.resumeProducing)
     self.conn.write('hi\r\n')
     result = with_timeout(DELAY * 10,
                           self.conn.read,
                           timeout_value='timed out')
     self.assertEqual('you said hi. BYE', result)
Пример #4
0
    def test_send(self):
        event1 = event()
        event2 = event()

        spawn(event1.send, 'hello event1')
        exc_after(0, ValueError('interrupted'))
        try:
            result = event1.wait()
        except ValueError:
            X = object()
            result = with_timeout(DELAY, event2.wait, timeout_value=X)
            assert result is X, 'Nobody sent anything to event2 yet it received %r' % (
                result, )
Пример #5
0
 def func():
     return with_timeout(0.2, sleep, 2, timeout_value=1)