SHARE
TWEET

Untitled

a guest Nov 27th, 2012 65 Never
  1. from twisted.internet import defer
  2.  
  3. def c(res):
  4.     print "HELLO!"
  5.     raise Exception()
  6.     return 2
  7.  
  8. def f(_):
  9.     print "HANDLED!"
  10.     return _
  11.  
  12. def end(_):
  13.     print "END!"
  14.     return _.value
  15.  
  16. def new_f(_):
  17.     print "HANDLED 2!"
  18.     return _
  19.  
  20. def a():
  21.     l = defer.Deferred()
  22.     l.addCallbacks(c, new_f)
  23.     d = defer.Deferred()
  24.     d.addCallback(c)
  25.     d.addErrback(f)
  26.     #if you comment this line all works as expected
  27.     d.chainDeferred(l)
  28.     d.addErrback(end)
  29.     return d
  30.  
  31. a().callback(2)
RAW Paste Data
Top