示例#1
0
def slow_fct():
    print "slow_fct"
    f1 = Future()
    def done():
        print "done"
        f1.set_result(3)
    reactor.call_later(0.1, done)
    return f1
示例#2
0
 def update_progress():
     global p
     r.set_progress(p)
     p += 5
     if p < 100:
         reactor.call_later(0.01, update_progress)
     else:
         reactor.stop()
示例#3
0
def slow_fct():
    print "slow_fct"
    f1 = Future()

    def done():
        print "done"
        f1.set_result(3)

    reactor.call_later(0.1, done)
    return f1
示例#4
0
 def test_inline_callbacks_exception1(self):
     reactor.reset()
     def print_result(result=None, error=None):
         assert error
         print "error", error[0]
     f = asynch_fct4()
     f.set_callback(print_result)
     
     reactor.call_later(1, reactor.stop)
     reactor.run()
     print "stop"
     assert f.completed
示例#5
0
 def test_inline_callbacks(self):
     reactor.reset()
     def print_result(result=None, error=None):
         print "result", result
         assert result == 18
     f = asynch_fct2()
     f.set_callback(print_result)
     
     reactor.call_later(0.6, reactor.stop)
     reactor.run()
     print "stop"
     assert f.completed
示例#6
0
 def test_cpu_bound(self):
     def print_result(result=None, error=None):
         print "result", result
         assert result == 2499997500000
     f1 = asynch_fct1("a")
     f2 = asynch_fct1("b")
     f1.set_callback(print_result)
     f2.set_callback(print_result)
     print "start"
     reactor.call_later(3, reactor.stop)
     reactor.run()
     print "stop"
示例#7
0
    def test_inline_callbacks_exception1(self):
        reactor.reset()

        def print_result(result=None, error=None):
            assert error
            print "error", error[0]

        f = asynch_fct4()
        f.set_callback(print_result)

        reactor.call_later(1, reactor.stop)
        reactor.run()
        print "stop"
        assert f.completed
示例#8
0
    def test_inline_callbacks(self):
        reactor.reset()

        def print_result(result=None, error=None):
            print "result", result
            assert result == 18

        f = asynch_fct2()
        f.set_callback(print_result)

        reactor.call_later(0.6, reactor.stop)
        reactor.run()
        print "stop"
        assert f.completed
示例#9
0
 def schedule_republish_transactions(self):
     seconds = random.randint(5 * 60, 30 * 60)
     reactor.call_later(seconds, self.republish_transactions)
示例#10
0
 def schedule_republish_transactions(self):
     seconds = random.randint(5 * 60, 30 * 60)
     reactor.call_later(seconds, self.republish_transactions)