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

Terry Jones terry at jon.es
Thu Jan 7 08:48:09 EST 2010


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

Glyph> This implies, to me, that the cancellation callback would be better
Glyph> passed to addCallbacks(): effectively creating a third callback
Glyph> chain going from invoker to responder rather than the other way
Glyph> 'round as callbacks and errbacks do.

After I went to bed I realized that someone is immediately going to want to
have a cancel function that returns a deferred. And what happens if
something goes wrong in a cancel function?

So you could end up with four chains, not two. And you could have
addCancelback *prepend* its functions to its chains, so that when the chain
is fired using the normal mechanism, it runs backwards.

So a deferred is running its callbacks from one end, and a client at the
other end calls the cancelback, which starts running callbacks from its
end.  And when the two meet? It's like the moment in Ghostbusters, when
they're screaming "Don't cross the streams! Don't cross the streams!"

The mind begins to boggle...  does madness that way lie?  Maybe not.

T



More information about the Twisted-Python mailing list