twisted.python.threadpool.ThreadPool.callInThreadWithCallback(self, onResult, func, *args, **kw)
method documentationtwisted.python.threadpool.ThreadPool
View Source
Call a callable object in a separate thread and call onResult
with the return value, or a twisted.python.failure.Failure
if the callable raises an exception.
The callable is allowed to block, but the onResult
function must not block and should perform as little work as possible.
A typical action for onResult
for a threadpool used with a Twisted reactor would be to schedule a twisted.internet.defer.Deferred
to fire in the main reactor thread using .callFromThread
. Note that onResult
is called inside the separate thread, not inside the reactor thread.
Parameters | onResult | a callable with the signature (success, result) . If the callable returns normally, onResult is called with (True, result) where result is the return value of the callable. If the callable throws an exception, onResult is called with (False, failure) .Optionally, |
func | callable object to be called in separate thread | |
args | positional arguments to be passed to func | |
kw | keyword arguments to be passed to func |
Function | inContext | Undocumented |