[Twisted-Python] addCallbacks issue

Sorin C. soso_pub at yahoo.com
Wed Apr 14 11:31:28 MDT 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:

1.
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

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)
"""
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,
Sorin



	
		
__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html




More information about the Twisted-Python mailing list