secret
Created

the 2nd chained deferred receives None as a result

  • Download Gist
twisted-deferred-none-result.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/usr/bin/env python
# http://stackoverflow.com/q/13634785
from twisted.internet import defer
 
class Baz:
def __init__(self):
self.resultD = defer.Deferred()
 
def fooMe(self, name):
d = defer.Deferred()
self.resultD.addCallback(d.callback) # or resultD.chainDeferred(d)
@d.addCallback
def f(result):
print "fooMe(%s) got: %s" % (name, result,)
assert result is not None
return result
return d
 
defer.Deferred.debug = True # get more info in traceback
b = Baz()
b.fooMe("one")
b.fooMe("two")
b.resultD.callback("result")

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.