[Twisted-Python] A pseudo-deferred class that can be canceled

Terry Jones terry at jon.es
Tue Jan 5 16:53:37 EST 2010

>>>>> "Glyph" == Glyph Lefkowitz <glyph at twistedmatrix.com> writes:

Glyph> And let's not forget, in long-running servers, it's possible to
Glyph> "leak" operations, and the associated resources like file
Glyph> descriptors.  When the caller says that they're not interested in
Glyph> the result of an operation any more, the library should clean up as
Glyph> much as possible, otherwise you'll start running out of those
Glyph> resources eventually.

Yes, but it shouldn't be the job of the caller to clean up something it has
no knowledge of.

I'm not sure if it's yet clear that I'm not trying *at all* to address
somehow stopping operations that are in progress. On the contrary, my code
always lets them run to their natural conclusion. It's just that if the
caller decides they're no longer interested in the result or that they want
the thing to fire right now, they can arrange for it. The originally called
code, including any err/callbacks that may be on the deferred it gave you,
is unaffected.

Using the word "cancel" in my original posting & class name was I guess
quite misleading.  Apologies for that. As usual I thought everyone would
know what I was talking about :-)

Is the simplified class that really is a Deferred (subclass) clearer?


More information about the Twisted-Python mailing list