def tearDown(self): http._logDateTimeStop() if self.port1 is not None: d = self.port1.stopListening() unittest.wait(d) if self.port2 is not None: d = self.port2.stopListening() unittest.wait(d)
def _reentrantWait(self): def threadedOperation(n): time.sleep(n) return n d1 = threads.deferToThread(threadedOperation, 0.125) d2 = threads.deferToThread(threadedOperation, 0.250) d1.addCallback(lambda ignored: unittest.wait(d2)) unittest.wait(d1)
def testEveryIteration(self): ran = [] def foo(): ran.append(None) if len(ran) > 5: lc.stop() lc = task.LoopingCall(foo) d = lc.start(0) x = unittest.wait(d) self.assertEquals(len(ran), 6)
def _cbDoWait(self, result): assertEquals(result, "Beginning") d = defer.succeed("End") assertEquals(unittest.wait(d), "End")
def wait(self, d, timeout=10.0): return unittest.wait(d, timeout=timeout)