l.s.twistedsupport : package documentation

Part of lp.services

Useful tools for interacting with Twisted.
Module features Feature flags for Twisted.
Module gracefulshutdown Utilities for graceful shutdown of Twisted services.
Module loggingsupport Integration between the normal Launchpad logging and Twisted's.
Module plugincache Build dropin.cache for all installed Twisted plugins.
Module processmonitor Helpers for running a child process and communicating things about it.
Module task Tools for managing long-running or difficult tasks with Twisted.
Package tests No package docstring; 6/6 modules documented
Module xmlrpc Support for XML-RPC stuff with Twisted.

From the __init__.py module:

Function cancel_on_timeout Cancel a Deferred if it doesn't fire before the timeout is up.
Function extract_result Extract the result from a fired deferred.
Function gatherResults Returns list with result of given Deferreds.
Function no_traceback_failures Decorator to return traceback-less Failures instead of raising errors.
Function run_reactor Run the reactor and return with the SIGCHLD handler unchanged.
Function suppress_stderr Deferred friendly decorator that suppresses output from a function.
def gatherResults(deferredList):
Returns list with result of given Deferreds.

This differs from Twisted's `defer.gatherResults` in two ways.

 1. It fires the actual first error that occurs, rather than wrapping
    it in a `defer.FirstError`.
 2. All errors apart from the first are consumed. (i.e. `consumeErrors`
    is True.)

:type deferredList:  list of `defer.Deferred`s.
:return: `defer.Deferred`.
def suppress_stderr(function):
Deferred friendly decorator that suppresses output from a function.
def extract_result(deferred):
Extract the result from a fired deferred.

It can happen that you have an API that returns Deferreds for compatibility with Twisted code, but is in fact synchronous, i.e. the Deferreds it returns have always fired by the time it returns. In this case, you can use this function to convert the result back into the usual form for a synchronous API, i.e. the result itself or a raised exception.

It would be very bad form to use this as some way of checking if a Deferred has fired.

def cancel_on_timeout(d, timeout, reactor=None):
Cancel a Deferred if it doesn't fire before the timeout is up.
ParametersdThe Deferred to cancel
timeoutThe timeout in seconds
reactorOverride the default reactor (useful for tests).
ReturnsThe same deferred, d.
def no_traceback_failures(func):
Decorator to return traceback-less Failures instead of raising errors.

This is useful for functions used as callbacks or errbacks for a Deferred. Traceback-less failures are much faster than the automatic Failures Deferred constructs internally.

def run_reactor():
Run the reactor and return with the SIGCHLD handler unchanged.
API Documentation for Launchpad, generated by pydoctor at 2018-02-24 00:00:04.