[Twisted-Python] understanding deferreds
Tristan Seligmann
mithrandi at mithrandi.net
Thu Jan 28 17:56:55 EST 2010
On Fri, Jan 29, 2010 at 12:39 AM, <exarkun at twistedmatrix.com> wrote:
> There are at least three ways you can have a single callback and
> errback:
>
> d.addCallback(cb)
> d.addErrback(eb)
>
> or
>
> d.addErrback(eb)
> d.addCallback(cb)
Just to expand on exarkun's answer a little, it might help to
understand that addCallback and addErrback are simply implemented in
terms of addCallbacks. Roughly:
def passthru(arg):
return arg
d.addCallback(cb) is equivalent to d.addCallbacks(cb, passthru)
d.addErrback(eb) is equivalent to d.addCallbacks(passthru, eb)
--
mithrandi, i Ainil en-Balandor, a faer Ambar
More information about the Twisted-Python
mailing list