[Twisted-Python] Cancel/stop Deferred() at any time
Simone Deponti
shywolf9982 at gmail.com
Wed Jul 15 09:06:46 EDT 2009
On 07/14/2009 06:37 PM, vitaly at synapticvision.com wrote:
>
> "cancel" callback - stop running now what you've been asked to exec.
> Example: some SQL query that takes 5 min and I need to cancel it
> anywhere in the middle and it, of course, it doesn't matter what the
> result set.
>
It seems like the problem you have is similar to what is described here:
http://www.dabeaz.com/python/GIL.pdf
Although this deals with Python's threading (and technology-wise, it's
completely unrelated to Twisted), the fundamental problems that they are
trying to solve are the same that Twisted tries to.
Unless I got it all wrong, you might need to "cancel the deferred"
because the actual operation being performed "locks" the CPU. The
example of the query taking five minutes is a bit misleading, I think,
because that is actually an operation that is deferred to an external
service and so it's more IO-bound than CPU-bound.
So maybe you do not actually need that. In case you do, as others have
pointed out, the application code must either "quit" by itself or some
sort of timeout (a "watchdog") has to be put in place.
Hope this will help and not confuse more ;)
Simone
More information about the Twisted-Python
mailing list