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
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)
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)
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, )
def func(): return with_timeout(0.2, sleep, 2, timeout_value=1)