Dear list,
I would like to add a callback that delays the chain. In other words I would like to combine: defer.Deferred().addCallback and reactor.callLater
The only solution I came up with was the code below.
There must be a more elegant way to do this. Any ideas would be greatly appreciated, All the best,
*************************begin from twisted.internet import reactor, defer
def printResults(results, arg): print "In printResults results=", results print "In printResults arg=", arg if arg == 2: reactor.stop()
def fireLater(results, d2): print "In fireLater results=", results reactor.callLater(5, d2.callback, "firelater")
d1 = defer.Deferred() d2 = defer.Deferred() d2.addCallback( printResults, 1) d2.addCallback( printResults, 2)
d1.addCallback(fireLater, d2) d1.callback("fire")
reactor.run() *************************end
Hi,
Arye wrote:
I would like to add a callback that delays the chain. In other words I would like to combine: defer.Deferred().addCallback and reactor.callLater
The only solution I came up with was the code below.
There must be a more elegant way to do this. Any ideas would be greatly appreciated, All the best,
*************************begin from twisted.internet import reactor, defer
def printResults(results, arg): print "In printResults results=", results print "In printResults arg=", arg if arg == 2: reactor.stop()
def fireLater(results, d2): print "In fireLater results=", results reactor.callLater(5, d2.callback, "firelater")
d1 = defer.Deferred() d2 = defer.Deferred() d2.addCallback( printResults, 1) d2.addCallback( printResults, 2)
d1.addCallback(fireLater, d2) d1.callback("fire")
reactor.run() *************************end
I've already written this some times:
d1.addCallback(5, reactor.callLater, d2.callback, "firelater")
Hope this, helps,
Hello and thanks for your time.
Regards,
I've already written this some times:
d1.addCallback(5, reactor.callLater, d2.callback, "firelater")
Hope this, helps,
-- Amaury Forgeot d'Arc
On Tue, Dec 16, 2008 at 5:29 PM, Arye aryeh@bigfoot.com wrote:
Dear list,
I would like to add a callback that delays the chain. In other words I would like to combine: defer.Deferred().addCallback and reactor.callLater
The only solution I came up with was the code below.
There must be a more elegant way to do this. Any ideas would be greatly appreciated, All the best,
*************************begin from twisted.internet import reactor, defer
def printResults(results, arg): print "In printResults results=", results print "In printResults arg=", arg if arg == 2: reactor.stop()
def fireLater(results, d2): print "In fireLater results=", results reactor.callLater(5, d2.callback, "firelater")
d1 = defer.Deferred() d2 = defer.Deferred() d2.addCallback( printResults, 1) d2.addCallback( printResults, 2)
d1.addCallback(fireLater, d2) d1.callback("fire")
reactor.run() *************************end