[Twisted-Python] addCallbacks issue

Sorin C. soso_pub at yahoo.com
Wed Apr 14 13:31:28 EDT 2004

Hello everybody,

Sorry for replying so late, I was very busy. Well I
think now I understand the difference between
addCallbacks and addCallback/errback.

Andrew, as you requested, here are a few pointers
which in my opinion would improve the documentation:

Stephen Thorne's code snippet made the "enlightement"
on me:

Maybe by making a parallel to imperitive style we can
make it clearer.

d = op()
d.addCallbacks(callback, errback)

is equivilient to

    r = op()
except e:
    return errback(e)
    return callback(r)

d = op()

is equivilient to

    return callback(op())
except e:
    return errback(e)
To make a long story short, using addCallbacks if an
error occures while processing the operation the
errback will be called. Using addCallback and
addErrback does the same AND also handles an error
that might occure in the callback code itself.
I think the code snippet and an explanation should be
added to the documentation.
Also, the figure from visual explanation, should be
specified that it is a representation of addCallbacks
usage. Wouldn't be better to add another figure that
represent addCallback/addErrback usage?
Hope this helps.

Thanks all for the explanations,

Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th

More information about the Twisted-Python mailing list