Extended thread dispatching support.

For basic support see reactor threading API docs.

Function deferToThreadPool Call the function f using a thread from the given threadpool and return the result as a Deferred.
Function deferToThread Run a function in a thread and return the result as a Deferred.
Function callMultipleInThread Run a list of functions in the same thread.
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 _runMultiple Run a list of functions.
def deferToThreadPool(reactor, threadpool, f, *args, **kwargs):

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.

ParametersreactorThe reactor in whose main thread the Deferred will be invoked.
threadpoolAn object which supports the callInThreadWithCallback method of twisted.python.threadpool.ThreadPool.
fThe function to call.
*argspositional arguments to pass to f.
**kwargskeyword arguments to pass to f.
ReturnsA 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 deferToThread(f, *args, **kwargs):

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

ParametersfThe function to call.
*argspositional arguments to pass to f.
**kwargskeyword arguments to pass to f.
ReturnsA 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):

Run a list of functions.

def callMultipleInThread(tupleList):

Run a list of functions in the same thread.

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

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

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.

ParametersreactorThe IReactorThreads provider which will be used to schedule the function call.
fthe callable to run in the reactor thread (type: any callable.)
athe arguments to pass to f.
kwthe keyword arguments to pass to f.
Returnsthe result of the Deferred returned by f, or the result of f if it returns anything other than a Deferred.
RaisesIf 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).
API Documentation for twisted, generated by pydoctor at 2020-03-25 17:34:30.