Table of Contents

Class: Deferred Twisted-0.19.0/twisted/internet/defer.py

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

Methods   
__init__
_continue
_runCallbacks
_startRunCallbacks
addBoth
addCallback
addCallbacks
addErrback
arm
callback
chainDeferred
errback
pause
setTimeout
unpause
  __init__ 
__init__ ( self )

  _continue 
_continue (
        self,
        result,
        isError,
        )

  _runCallbacks 
_runCallbacks ( self )

  _startRunCallbacks 
_startRunCallbacks (
        self,
        result,
        isError,
        )

Exceptions   
AlreadyCalledError()
  addBoth 
addBoth (
        self,
        callback,
        *args,
        *kw,
        )

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

See addCallbacks.

  addCallback 
addCallback (
        self,
        callback,
        *args,
        *kw,
        )

Convenience method for adding just a callback.

See addCallbacks.

  addCallbacks 
addCallbacks (
        self,
        callback,
        errback=None,
        callbackArgs=None,
        callbackKeywords=None,
        errbackArgs=None,
        errbackKeywords=None,
        asDefaults=0,
        )

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

These will be executed when the master callback is run.

  addErrback 
addErrback (
        self,
        errback,
        *args,
        *kw,
        )

Convenience method for adding just an errback.

See addCallbacks.

  arm 
arm ( self )

This method is deprecated.

  callback 
callback ( self,  result )

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.

If this deferred has not been armed yet, nothing will happen until it is armed.

  chainDeferred 
chainDeferred ( self,  d )

Chain another Deferred to this Deferred.

This method adds callbacks to this Deferred to call d's callback or errback, as appropriate.

  errback 
errback ( self,  fail=None )

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.

If this deferred has not been armed yet, nothing will happen until it is armed.

  pause 
pause ( self )

Stop processing on a Deferred until unpause() is called.

  setTimeout 
setTimeout (
        self,
        seconds,
        timeoutFunc=timeout,
        )

Set a timeout function to be triggered if I am not called.

timeoutFunc will receive the Deferred as its only argument. The default timeoutFunc will call the errback with a TimeoutError.

The timeout counts down from when this method is called.

  unpause 
unpause ( self )

Process all callbacks made since pause() was called.


Table of Contents

This document was automatically generated on Sun Jul 14 19:52:41 2002 by HappyDoc version 2.0