<div dir="ltr">Hi Tom<div><br></div><div>> <span style="font-family:arial,sans-serif;font-size:13px">Since most apis in twisted don't pass a canceller, the behavior is </span><span style="font-family:arial,sans-serif;font-size:13px">a2+a3.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:13px">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, </span><span style="font-family:arial,sans-serif;font-size:13px">Kai Zhang is now adding cancellers to some apis returning deferreds, starting with the POP3 client.</span></div>
<div style><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:13px">Based on JP's comment, I still think I'm missing something here. </span></div>
<div style><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:13px">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</span></div>
<div style><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div style><div style><font face="arial, sans-serif">In [1]: from twisted.internet.defer import CancelledError</font></div>
</div><div style><div style><font face="arial, sans-serif">In [2]: e = CancelledError('hey')</font></div></div><div style><div style><font face="arial, sans-serif">In [3]: e.args[0]</font></div></div><div style><div style>
<font face="arial, sans-serif">Out[3]: 'hey'</font></div></div></blockquote><div style><div style="font-family:arial,sans-serif;font-size:13px"><br></div></div><div style><span style="font-family:arial,sans-serif;font-size:13px">Terry</span></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 21, 2013 at 6:12 AM, Tom Prince <span dir="ltr"><<a href="mailto:tom.prince@ualberta.net" target="_blank">tom.prince@ualberta.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">Terry Jones <<a href="mailto:terry@jon.es">terry@jon.es</a>> writes:<br>
> OK, maybe someone can explain the original "Well, it already raises<br>
> `CancelledError`. Every deferred that doesn't have explicitly handle<br>
> cancelling already does:" to me, because I didn't get it at all!<br>
<br>
</div>This is what happens when a deferred is cancelled:<br>
<br>
a) If the deferred hasn't been errbacked:<br>
   1. Call the provied canceller (provided when the deferred is constructed)<br>
   2. If a canceller isn't provided, or if the canceller didn't<br>
      callback/errback, then errback with CancelledError.<br>
   3. If a canceller isn't provided, allow callback/errback to be called<br>
      without error once.<br>
b) If the deferred has been fired, and is waiting on another deferred,<br>
   cancel that deferred instead.<br>
<br>
Since most apis in twisted don't pass a canceller, the behavior is<br>
a2+a3.<br>
<span class="HOEnZb"><font color="#888888"><br>
  Tom<br>
<br>
</font></span></blockquote></div><br></div>