t.i.d.Deferred : class documentation

Part of twisted.internet.defer View Source View In Hierarchy

Known subclasses: twisted.flow.controller.Deferred, twisted.internet.defer.DeferredList, twisted.persisted.crefutil._Defer

This is a callback which will be put off until later.

Why do we want this? Well, in cases where a function in a threaded program would block until it gets a result, for Twisted it should not block. Instead, it should return a Deferred.

This can be implemented for protocols that run over the network by writing an asynchronous protocol for twisted.internet. For methods that come from outside packages that are not under our control, we use threads (see for example twisted.enterprise.adbapi).

For more information about Deferreds, see doc/howto/defer.html or http://twistedmatrix.com/projects/core/documentation/howto/defer.html
Method __init__ Undocumented
Method addCallbacks Add a pair of callbacks (success and error) to this Deferred.
Method addCallback Convenience method for adding just a callback.
Method addErrback Convenience method for adding just an errback.
Method addBoth Convenience method for adding a single callable as both a callback and an errback.
Method chainDeferred Chain another Deferred to this Deferred.
Method callback Run all success callbacks that have been added to this Deferred.
Method errback Run all error callbacks that have been added to this Deferred.
Method pause Stop processing on a Deferred until unpause() is called.
Method unpause Process all callbacks made since pause() was called.
Method setTimeout Set a timeout function to be triggered if I am not called.
Method __str__ Undocumented
Method _continue Undocumented
Method _startRunCallbacks Undocumented
Method _runCallbacks Undocumented
def __init__(self): (source)
Undocumented
def addCallbacks(self, callback, errback=None, callbackArgs=None, callbackKeywords=None, errbackArgs=None, errbackKeywords=None): (source)

Add a pair of callbacks (success and error) to this Deferred.

These will be executed when the 'master' callback is run.
def addCallback(self, callback, *args, **kw): (source)

Convenience method for adding just a callback.

See addCallbacks.
def addErrback(self, errback, *args, **kw): (source)

Convenience method for adding just an errback.

See addCallbacks.
def addBoth(self, callback, *args, **kw): (source)

Convenience method for adding a single callable as both a callback and an errback.

See addCallbacks.
def chainDeferred(self, d): (source)

Chain another Deferred to this Deferred.

This method adds callbacks to this Deferred to call d's callback or errback, as appropriate. It is merely a shorthand way of performing the following:
   self.addCallbacks(d.callback, d.errback)
When you chain a deferred d2 to another deferred d1 with d1.chainDeferred(d2), you are making d2 participate in the callback chain of d1. Thus any event that fires d1 will also fire d2. However, the converse is not true; if d2 is fired d1 will not be affected.
def callback(self, result): (source)

Run all success callbacks that have been added to this Deferred.

Each callback will have its result passed as the first argument to the next; this way, the callbacks act as a 'processing chain'. Also, if the success-callback returns a Failure or raises an Exception, processing will continue on the *error*- callback chain.
def errback(self, fail=None): (source)

Run all error callbacks that have been added to this Deferred.

Each callback will have its result passed as the first argument to the next; this way, the callbacks act as a 'processing chain'. Also, if the error-callback returns a non-Failure or doesn't raise an Exception, processing will continue on the *success*-callback chain.

If the argument that's passed to me is not a failure.Failure instance, it will be embedded in one. If no argument is passed, a failure.Failure instance will be created based on the current traceback stack.

Passing a string as `fail' is deprecated, and will be punished with a warning message.
RaisesNoCurrentExceptionErrorIf fail is None but there is no current exception state.
def pause(self): (source)
Stop processing on a Deferred until unpause() is called.
def unpause(self): (source)
Process all callbacks made since pause() was called.
def _continue(self, result): (source)
Undocumented
def _startRunCallbacks(self, result): (source)
Undocumented
def _runCallbacks(self): (source)
Undocumented
def setTimeout(self, seconds, *args, timeoutFunc=timeout, **kw): (source)
Set a timeout function to be triggered if I am not called.
ParameterssecondsHow long to wait (from now) before firing the timeoutFunc.
timeoutFuncwill receive the Deferred and *args, **kw as its arguments. The default timeoutFunc will call the errback with a TimeoutError.
def __str__(self): (source)
Undocumented
API Documentation for Twisted, generated by pydoctor at 2011-10-27 15:57:47.