コード例 #1
0
    def testWaitFor(self):
        cb = reactor.callLater(5, reactor.crash)
        self.assertRaises(testreactor.EarlyExit,
                          lambda: reactor.waitFor(10, early_ok=False))
        self.failIf(cb.active())  # The callback should've fired

        # The waitFor() does its scheduling *after* the callLater,
        # so its callback should fire second, assuming that the
        # reactor uses a stable sorting algorithm to schedule callbacks
        # Thus, even though the timeout is scheduled for the same moment
        # of simulated time, the following should not raise an error.
        cb = reactor.callLater(5, reactor.crash)
        reactor.waitFor(5, early_ok=False)
        self.failIf(cb.active())  # The callback should've fired

        # Finally, test some simple cases...
        cb = reactor.callLater(3, reactor.crash)
        reactor.waitFor(2)
        self.failUnless(cb.active())  # The callback shouldn't have fired yet

        reactor.waitFor(1)
        self.failIf(cb.active())  # Now it should've fired
コード例 #2
0
ファイル: TestTestReactor.py プロジェクト: HackLinux/chandler
    def testWaitFor(self):
        cb = reactor.callLater(5, reactor.crash)
        self.assertRaises(
            testreactor.EarlyExit,
            lambda: reactor.waitFor(10, early_ok=False)
        )
        self.failIf(cb.active())    # The callback should've fired

        # The waitFor() does its scheduling *after* the callLater,
        # so its callback should fire second, assuming that the
        # reactor uses a stable sorting algorithm to schedule callbacks
        # Thus, even though the timeout is scheduled for the same moment
        # of simulated time, the following should not raise an error.
        cb = reactor.callLater(5, reactor.crash)
        reactor.waitFor(5, early_ok=False)
        self.failIf(cb.active())    # The callback should've fired

        # Finally, test some simple cases...
        cb = reactor.callLater(3, reactor.crash)
        reactor.waitFor(2)
        self.failUnless(cb.active())    # The callback shouldn't have fired yet

        reactor.waitFor(1)
        self.failIf(cb.active())    # Now it should've fired
コード例 #3
0
 def testReactorResetsScheduledCalls(self):
     reactor.callLater(5, reactor.crash)
     reactor.waitFor(3)
     reactor.start()  # reset reactor completely
     reactor.waitFor(10, False)  # this should fail if callback is active
コード例 #4
0
ファイル: TestTestReactor.py プロジェクト: HackLinux/chandler
 def testReactorResetsScheduledCalls(self):
     reactor.callLater(5, reactor.crash)
     reactor.waitFor(3)
     reactor.start()     # reset reactor completely
     reactor.waitFor(10, False)  # this should fail if callback is active