【发布时间】:2010-08-02 19:23:24
【问题描述】:
我们可以使用 deferred (http://twistedmatrix.com/documents/current/core/howto/defer.html) 来进行无限调用循环,其中函数将自身添加到延迟链中吗?我试图这样做,但它不起作用:
d = deferred.Deferred()
first = True
def loopPrinting(dump):
ch = chr(random.randint(97, 122))
print ch
global d, first
d.addCallback(loopPrinting)
if first:
d.callback('a')
first = False
return d
loopPrinting('a')
reactor.run()
【问题讨论】: