[Twisted-Python] If the errbacks of a canceled Deferred are called with error other than CancelledError, is this acceptable?
Terry Jones
terry at jon.es
Fri Jun 21 04:26:01 MDT 2013
Hi Tom
> Since most apis in twisted don't pass a canceller, the behavior is a2+a3.
Right. That was the intention (glyph's). It was expected that over time
more Twisted apis that create deferreds would add cancellers. As I
understand it, Kai Zhang is now adding cancellers to some apis returning
deferreds, starting with the POP3 client.
Based on JP's comment, I still think I'm missing something here.
The only suggestion I've been making is that, if we wanted to, we could
allow a value to be passed to the cancel call. That would allow errback
functions to receive more information when a Deferred is canceled. You'd
still get a CancelledError in any case, but the value would be in the
exception instance as args[0], as in
In [1]: from twisted.internet.defer import CancelledError
In [2]: e = CancelledError('hey')
In [3]: e.args[0]
Out[3]: 'hey'
Terry
On Fri, Jun 21, 2013 at 6:12 AM, Tom Prince <tom.prince at ualberta.net> wrote:
> Terry Jones <terry at jon.es> writes:
> > OK, maybe someone can explain the original "Well, it already raises
> > `CancelledError`. Every deferred that doesn't have explicitly handle
> > cancelling already does:" to me, because I didn't get it at all!
>
> This is what happens when a deferred is cancelled:
>
> a) If the deferred hasn't been errbacked:
> 1. Call the provied canceller (provided when the deferred is
> constructed)
> 2. If a canceller isn't provided, or if the canceller didn't
> callback/errback, then errback with CancelledError.
> 3. If a canceller isn't provided, allow callback/errback to be called
> without error once.
> b) If the deferred has been fired, and is waiting on another deferred,
> cancel that deferred instead.
>
> Since most apis in twisted don't pass a canceller, the behavior is
> a2+a3.
>
> Tom
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20130621/3b6340c1/attachment-0002.html>
More information about the Twisted-Python
mailing list