ねじれたのは初めてで、延期されたものを試しているところです。100 の遅延呼び出しのリストを構成する次のコードがあります。それぞれがランダムな時間を待機し、値を返します。そのリストは結果を出力し、最後にリアクターを終了します。
しかし、私が原子炉を止める方法はおそらく... 良くないと確信しています。
__author__ = 'Charlie'
from twisted.internet import defer, reactor
import random
def getDummyData(x):
    """returns a deferred object that will have a value in some random seconds
    sets up a callLater on the reactor to trgger the callback of d"""
    d = defer.Deferred()
    pause = random.randint(1,10)
    reactor.callLater(pause, d.callback, (x, pause))
    return d
def printData(result):
    """prints whatever is passed to it"""
    print result
def main():
    """makes a collection of deffered calls and then fires them. Stops reactor at end"""
    deferred_calls = [getDummyData(r) for r in range(0,100)]
    d = defer.gatherResults(deferred_calls, consumeErrors = True)
    d.addCallback(printData)
    # this additional callback on d stops the reacor
    # it fires after all the delayed callbacks have printed their values
    # the lambda ignored: ractor.stop() is required as callback takes a function
    # that takes a parameter.
    d.addCallback(lambda ignored: reactor.stop())
    # start the reactor.
    reactor.run()
if __name__ == "__main__":
    main()
私は、コールバックを追加することによってそれを想定しています:
d.addCallback(lambda ignored: reactor.stop())
収集された結果に実際にそのコールバックをすべての遅延アイテムに追加しますか?
もしそうなら、おそらくもっとエレガントで正しい方法がありますか?
乾杯!