timer 总是不能少的东西。我们来看看 twisted 中 timer 咋用。
只调用一次
-------------------------------------------------
from twisted.internet import reactor
def f(s):
print "s = %s" % s
reactor.callLater(3.5, f, "hello!")
reactor.run()
-------------------------------------------------
连续调用
-------------------------------------------------
from twisted.internet import task
from twisted.internet import reactor
def foo():
print "foo!"
l = task.LoopingCall(foo)
l.start(1.0)
# l.stop will stop the looping calls
reactor.run()
-------------------------------------------------
评论