Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

the 2nd chained deferred receives None as a result

View twisted-deferred-none-result.py
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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.