Re: [Twisted-Python] Raising exception from a Deferred canceller.

2013-08-29 Thread Glyph
Thank you, Kai, for a great post describing the issue in detail. On Aug 29, 2013, at 2:27 AM, zhang kai wrote: > So, what’s your opinion on raising an exception from the canceller? I feel pretty strongly that it ought to be handled in this manner: Index: twisted/internet/defer.py =

Re: [Twisted-Python] Raising exception from a Deferred canceller.

2013-08-29 Thread Terry Jones
JP writes: On Thu, Aug 29, 2013 at 1:00 PM, wrote: > Keep in mind that the Deferred cancellation API is a "best effort" API. > There are no guarantees that anything can be cancelled. Consider the fact > that 90% or more of Deferreds out there don't even have cancellation > implemented for them

Re: [Twisted-Python] Raising exception from a Deferred canceller.

2013-08-29 Thread Terry Jones
JP writes: On Thu, Aug 29, 2013 at 1:00 PM, wrote: > What about a third option - if a cancellation function raises an > exception, fail the Deferred with that exception. I really like this idea, but it wont work if the cancel function has already fired the deferred. Terry

Re: [Twisted-Python] Raising exception from a Deferred canceller.

2013-08-29 Thread exarkun
On 10:18 am, te...@jon.es wrote: Hi Kai [snip] 2b) there is some kind of exception when cancel calls the cancellation function. I don't think 2a) is really an exception situation, so it makes sense, as you say, just to return False from cancel in this case. It's basically the cancel function

Re: [Twisted-Python] Raising exception from a Deferred canceller.

2013-08-29 Thread exarkun
On 09:27 am, kylerzhan...@gmail.com wrote: Hi, As itamar mentioned in ticket #6676 , If a cancellation function for a Deferred throws an exception(the cancel() method of Deferred won’t throw exceptions, but the canceller may), behavior is undefined. If the cancellation func

Re: [Twisted-Python] Raising exception from a Deferred canceller.

2013-08-29 Thread Terry Jones
Hi Kai I think it's helpful to keep clear on two different things that cancelation is intended to do: 1) to fire the original deferred so that things relying on it can proceed, and 2) to try to terminate an ongoing action that the deferred might be waiting on. For 1, I think calling cancel() shou

[Twisted-Python] Raising exception from a Deferred canceller.

2013-08-29 Thread zhang kai
Hi, As itamar mentioned in ticket #6676 , If a cancellation function for a Deferred throws an exception(the cancel() method of Deferred won’t throw exceptions, but the canceller may), behavior is undefined. If the cancellation function throws an exception it is currently not ca