[Twisted-Python] chainDeferred does not pass result

"Lutz Pälike" lutz_p at gmx.net
Thu May 29 10:06:56 EDT 2008

I was trying to chain two Deferreds together but there is a problem with chainDeferred().
If i add  Deferred object b in the middle of the call chain of  object a, the result is correctly passed on to the branched call chain of b but the call chain of a is broken because b.callback() does not return a result.

Am i missing something or is this a bug ?

The example below illustrates the problem. If you uncomment the line 
you should see 
result:  None



from twisted.internet import defer, reactor

def square(res):
  return res*res

def on_result(res):
  print "result: ", res
  return res

def on_error(err):
  print err
  return err

deferred_a = defer.Deferred()
deferred_b = defer.Deferred()

# deferred_a.chainDeferred(deferred_b)
deferred_a.addCallbacks(on_result, on_error)

reactor.callLater(0.0, deferred_a.callback, 3)
reactor.callLater(1.0, reactor.stop)


Super-Aktion nur in der GMX Spieleflat: 10 Tage für 1 Euro.
Über 180 Spiele downloaden: http://flat.games.gmx.de

More information about the Twisted-Python mailing list