This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 27th, 2012  |  syntax: Python  |  size: 0.52 KB  |  views: 62  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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)
clone this paste RAW Paste Data