twisted.internet.defer

Package twisted :: Package internet :: Module defer |
[frames | no frames]

## Module twisted.internet.defer

Support for results that aren't immediately available.

API Stability: stable

Maintainer: Glyph Lefkowitz

Classes
`_nothing` |
`Deferred` | This is a callback which will be put off until later.
`DeferredList` | I combine a group of deferreds into one callback.

Exceptions
`AlreadyArmedError` |
`AlreadyCalledError` |
`TimeoutError` |

Function Summary
| `_parseDListResult(l, fireOnOneErrback)`
| ``execute`(callable, *args, **kw)` Create a deferred from a callable and arguments.
`Deferred` | ``fail`(result)` Return a Deferred that has already had '.errback(result)' called.
| ``gatherResults`(deferredList, fireOnOneErrback)` Returns list with result of given Deferreds.
| `logError(err)`
`Deferred` | ``maybeDeferred`(f, *args, **kw)` Invoke a function that may or may not return a deferred.
| `passthru(arg)`
`Deferred` | ``succeed`(result)` Return a Deferred that has already had '.callback(result)' called.
| `timeout(deferred)`

Variable Summary
`int` | `FAILURE` = 0
`int` | `SUCCESS` = 1

Function Details

### execute(callable, *args, **kw) Create a deferred from a callable and arguments. Call the given function with the given arguments. Return a deferred which has been fired with its callback as the result of that invocation or its errback with a Failure for the exception thrown.

### fail(result=<class twisted.internet.defer._nothing at 0x82a9674>) Return a Deferred that has already had '.errback(result)' called. See `succeed`'s docstring for rationale. Parameters: `result` - The same argument that `Deferred.errback` takes. Returns: `Deferred`

### gatherResults(deferredList, fireOnOneErrback=0) Returns list with result of given Deferreds. This builds on `DeferredList` but is useful since you don't need to parse the result for success/failure. Parameters: `deferredList` (type=`list` of `Deferred`s)

### maybeDeferred(f, *args, **kw) Invoke a function that may or may not return a deferred. Call the given function with the given arguments. If the returned object is a `Deferred`, return it. If the returned object is a `Failure`, wrap it with `fail` and return it. Otherwise, wrap it in `succeed` and return it. If an exception is raised, convert it to a `Failure`, wrap it in `fail`, and then return it. Parameters: `f` - The callable to invoke (type=Any callable) `args` - The arguments to pass to `f` `kw` - The keyword arguments to pass to `f` Returns: The result of the function call, wrapped in a `Deferred` if necessary. API Stability: Unstable (type=`Deferred`)

### succeed(result) Return a Deferred that has already had '.callback(result)' called. This is useful when you're writing synchronous code to an asynchronous interface: i.e., some code is calling you expecting a Deferred result, but you don't actually need to do anything asynchronous. Just return defer.succeed(theResult). See `fail` for a version of this function that uses a failing Deferred rather than a successful one. Parameters: `result` - The result to give to the Deferred's 'callback' method. Returns: `Deferred`

Variable Details

    ### FAILURE Type: `int` Value:
        0

    ### SUCCESS Type: `int` Value:
        1

Generated by Epydoc 2.0 on Sat May 15 20:08:48 2004 | http://epydoc.sf.net