[Twisted-Python] Re: [Twisted-commits] Accumulated Woven Changes::

Andrew Bennetts andrew-twisted at puzzling.org
Mon Oct 14 12:31:56 EDT 2002


On Mon, Oct 14, 2002 at 05:39:45PM +0200, Christopher Armstrong wrote:
> > radix CVS wrote:
> > >3) changed some addCallback/addErrback to addCallbacks
> 
> Sorry, I've brain-farted. I knew they were semantic changes, but
> usually addCallbacks is recommended; I didn't realize that these
> particular semantics were really needed in this case.

This makes me wonder if most of the time you want to add a callback and an
errback, you want the errback to be able to catch the callbacks errors.

That is, maybe
    d.addCallbacks(cb, eb)
should be changed to be equivalent to 
    d.addCallback(cb).addErrback(eb)
and anyone requiring the current behaviour would have to do
    d.addErrback(eb).addCallback(cb)

Although now that I think of it, that last example isn't *quite* the same as
the current behaviour if eb returns a non-Failure...

I'm just thinking that the most commonly desired behaviour is to mirror
    try:
        cb()
    except:
        eb()

Hmm.  Perhaps a better solution is to add a kwarg to addCallbacks, so that
something like
    d.addCallbacks(cb, eb, errbackCatchesCallback=1)
would modify it to do what you want.  It'd be nice to think of a nicer name
for the kwarg though.

I guess it depends on what the most common use-case for adding callbacks &
errbacks is, and whether that is important enough to change the interface.
It's probably too late to do this with 1.0 so close :(

-Andrew.





More information about the Twisted-Python mailing list