[Twisted-Python] addCallbacks issue
Stephen Thorne
stephen at thorne.id.au
Tue Apr 13 07:57:10 EDT 2004
On Tue, Apr 13, 2004 at 08:31:46PM +1000, Andrew Bennetts wrote:
> On Tue, Apr 13, 2004 at 01:19:30AM -0700, Sorin C. wrote:
> > Hi,
> >
> > Yes, I saw this bit of documentation but what I
> > understand from it is that if you chain multiple
> > addCallbacks to the same deferred then the error
> > handler from the last addCallbacks call will be
> > called. What am I missing?
>
> You misunderstand the documentation, which is a shame because that section
> is there specifically to be as clear as possible about this point :( I
> wonder how we can do better?
>
Maybe by making a parallel to imperitive style we can make it clearer.
d = op()
d.addCallbacks(callback, errback)
is equivilient to
try:
r = op()
except e:
return errback(e)
else:
return callback(r)
d = op()
d.addCallback(callback).addErrback(errback)
is equivilient to
try:
return callback(op())
except e:
return errback(e)
Regards,
Stephen Thorne
More information about the Twisted-Python
mailing list