On Tue, 14 Jul 2009 11:10:10 -0400, [email protected] wrote:
>Hello,
>
>is there any way to cancel the Deferred callback in those examples?
>
>1.
>d = defer.Deferred()
>d.addCallback(methodA).addErrback(methodErr)
>d.callback(None)
>
>2.
>d = methodB().addErrback(methodErr)
>wfd = defer.waitForDeferred(d)
>
>
>
>Appreciate any help.
>

Deferred doesn't have any cancellation features.  You can generally achieve
some sort of cancellation by supporting this in the application code creating
and consuming the Deferreds involved.

The details of how to do this depend on what exactly you want to happen when
you "cancel" the operation.

You can find one example of this in the implementation of Twisted's internal
thread-based name resolver:

http://twistedmatrix.com/trac/browser/trunk/twisted/internet/base.py#L193

You can find other examples in the implementation of any other Deferred-
returning API which also supports timeouts, eg the web client:

http://twistedmatrix.com/trac/browser/trunk/twisted/web/client.py#L198

Hope this helps,

Jean-Paul

_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to