[Twisted-Python] How to safely stop a chain of deferreds

Terry Jones terry at jon.es
Tue Jun 28 10:14:38 EDT 2011


Hi Tom

> in a GUI application I'm using quite a comprehensive chain of deferreds
> and I'm running the mainloop from the glib2reactor. At a certain point of
> my application I need to terminate the entire chain of deferreds to make
> sure that no more data is loaded and processed. Stopping the reactor does
> not work as the entire GUI would terminate, too. I tried to cancel the
> first deferred, hoping that the cancel event will be forwarded to the
> next deferred in the chain or at least invoke an errback, but for some
> reason it does not work and the deferreds seem to run forever. Any ideas
> on how to solve this issue?

It's a bit hard to know how to help without more detail.  Code you paste
some code somewhere?  I'm sorry if this sounds picky, but your description
is a bit vague. E.g., there's no such thing as a "chain of deferreds" (do
you mean chain of callbacks on a single deferred? or a callbacks that
return deferreds etc?) and e.g., "deferreds seem to run forever" but
deferreds don't run at all, callbacks do. If you can make it a bit more
precise I'll be happy to try to help.

Terry



More information about the Twisted-Python mailing list