### Navigation

- index
- modules |
- next |
- previous |
- IPython v0.10.1 documentation »
- The IPython API »

# kernel.twistedutil

## Module: `kernel.twistedutil`

Inheritance diagram for `IPython.kernel.twistedutil`:

Things directly related to all of twisted.

## Classes

### `DeferredList`

class `IPython.kernel.twistedutil.``DeferredList`(deferredList, fireOnOneCallback=0, fireOnOneErrback=0, consumeErrors=0, logErrors=0)

  Bases: `twisted.internet.defer.Deferred`

  I combine a group of deferreds into one callback.

  I track a list of L{Deferred}s for their callbacks, and make a single callback when they have all completed, a list of (success, result) tuples, ‘success’ being a boolean.

  Note that you can still use a L{Deferred} after putting it in a DeferredList. For example, you can suppress ‘Unhandled error in Deferred’ messages by adding errbacks to the Deferreds after putting them in the DeferredList, as a DeferredList won’t swallow the errors. (Although a more convenient way to do this is simply to set the consumeErrors flag)

  Note: This is a modified version of the twisted.internet.defer.DeferredList

  `__init__`()

    Initialize a DeferredList.

    @type deferredList: C{list} of L{Deferred}s @param deferredList: The list of deferreds to track. @param fireOnOneCallback: (keyword param) a flag indicating that

    > only one callback needs to be fired for me to call my callback

    @param fireOnOneErrback: (keyword param) a flag indicating that
      only one errback needs to be fired for me to call my errback
    @param consumeErrors: (keyword param) a flag indicating that any errors
      raised in the original deferreds should be consumed by this DeferredList. This is useful to prevent spurious warnings being logged.

### `ReactorInThread`

class `IPython.kernel.twistedutil.``ReactorInThread`(group=None, target=None, name=None, args=(), kwargs=None, verbose=None)

  Bases: `threading.Thread`

  Run the twisted reactor in a different thread.

  For the process to be able to exit cleanly, do the following:

  rit = ReactorInThread() rit.setDaemon(True) rit.start()

  `__init__`()
  `run`()
  `stop`()

## Functions

`IPython.kernel.twistedutil.``gatherBoth`()

  This is like gatherBoth, but sets consumeErrors=1.

`IPython.kernel.twistedutil.``parseResults`()

  Pull out results/Failures from a DeferredList.

`IPython.kernel.twistedutil.``wait_for_file`()

  Wait (poll) for a file to be created.

  This method returns a Deferred that will fire when a file exists. It works by polling os.path.isfile in time intervals specified by the delay argument. If max_tries is reached, it will errback with a FileTimeoutError.

  Parameters : | filename : str The name of the file to wait for. delay : float The time to wait between polls. max_tries : int The max number of attempts before raising FileTimeoutError
  Returns : | d : Deferred A Deferred instance that will fire when the file exists.

### Navigation

- index
- modules |
- next |
- previous |
- IPython v0.10.1 documentation »
- The IPython API »