Table of Contents

Class: Deferred | Twisted-0.17.4/twisted/python/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).

Methods |
--- | ---

__init__ _runCallbacks addCallback addCallbacks addErrback arm | armAndCallback armAndChain armAndErrback callback chainDeferred errback

| __init__

    __init__ ( self )

| _runCallbacks

    _runCallbacks (
            self,
            result,
            isError,
            )

| addCallback

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

| 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.

Exceptions |
--- | ---
AlreadyArmedError( "You cannot add callbacks after a deferred" "has already been armed." )

| addErrback

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

| arm

    arm ( self )

### State that this function is ready to be called.

This is to prevent callbacks from being executed sometimes synchronously and sometimes asynchronously. The system expecting a Deferred will explicitly arm the delayed after it has been returned; at that point, it may fire later.

| armAndCallback

    armAndCallback ( self,  result )

Utility method to arm me and immediately issue a callback.

| armAndChain

    armAndChain ( self,  deferred )

### Utility method to add another deferred to me as a set of callbacks.

#### Arguments:

deferred: the Deferred to be armed and fired when my callback arrives.

| armAndErrback

    armAndErrback ( self,  error )

Utility method to arm me and immediately issue an error callback.

| 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 )

| errback

    errback ( self,  error )

### 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.

Table of Contents

This document was automatically generated on Sat Apr 20 01:31:23 2002 by HappyDoc version 2.0