我们可以使用延迟(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()