Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`internet`.`threads``

module documentation
(source)

Extended thread dispatching support.

For basic support see reactor threading API docs.

Function | `blockingCallFromThread` | Run a function in the reactor from a thread, and wait for the result synchronously. If the function returns a `Deferred`, wait for its result and return that.
Function | `callMultipleInThread` | Run a list of functions in the same thread.
Function | `deferToThread` | Run a function in a thread and return the result as a Deferred.
Function | `deferToThreadPool` | Call the function `f` using a thread from the given threadpool and return the result as a Deferred.
Function | `_runMultiple` | Run a list of functions.

def blockingCallFromThread(reactor, f, *a, **kw): (source)

Run a function in the reactor from a thread, and wait for the result synchronously. If the function returns a `Deferred`, wait for its result and return that.

Parameters
reactor | The `IReactorThreads` provider which will be used to schedule the function call.
f:any callable. | the callable to run in the reactor thread
*a | the arguments to pass to `f`.
**kw | the keyword arguments to pass to `f`.
Returns
the result of the `Deferred` returned by `f`, or the result of `f` if it returns anything other than a `Deferred`.
Raises
`Exception` | If `f` raises a synchronous exception, `blockingCallFromThread` will raise that exception. If `f` returns a `Deferred` which fires with a `Failure`, `blockingCallFromThread` will raise that failure's exception (see `Failure.raiseException`).

def callMultipleInThread(tupleList): (source)

Run a list of functions in the same thread.

tupleList should be a list of (function, argsList, kwargsDict) tuples.

def deferToThread(f, *args, **kwargs): (source)

Run a function in a thread and return the result as a Deferred.

Parameters
f | The function to call.
*args | positional arguments to pass to f.
**kwargs | keyword arguments to pass to f.
Returns
A Deferred which fires a callback with the result of f, or an errback with a `twisted.python.failure.Failure` if f throws an exception.

def deferToThreadPool(reactor, threadpool, f, *args, **kwargs): (source)

Call the function `f` using a thread from the given threadpool and return the result as a Deferred.

This function is only used by client code which is maintaining its own threadpool. To run a function in the reactor's threadpool, use `deferToThread`.

Parameters
reactor | The reactor in whose main thread the Deferred will be invoked.
threadpool | An object which supports the `callInThreadWithCallback` method of `twisted.python.threadpool.ThreadPool`.
f | The function to call.
*args | positional arguments to pass to f.
**kwargs | keyword arguments to pass to f.
Returns
A Deferred which fires a callback with the result of f, or an errback with a `twisted.python.failure.Failure` if f throws an exception.

def _runMultiple(tupleList): (source)

Run a list of functions.