def deferToThread(f, *args, **kwargs):
    '\n    Run a function in a thread and return the result as a Deferred.\n\n    @param f: The function to call.\n    @param *args: positional arguments to pass to f.\n    @param **kwargs: keyword arguments to pass to f.\n\n    @return: A Deferred which fires a callback with the result of f,\n    or an errback with a L{twisted.python.failure.Failure} if f throws\n    an exception.\n    '
    from twisted.internet import reactor
    return deferToThreadPool(reactor, reactor.getThreadPool(), f, *args, **kwargs)
Run a function in a thread and return the result as a Deferred.

@param f: The function to call.
@param *args: positional arguments to pass to f.
@param **kwargs: keyword arguments to pass to f.

@return: A Deferred which fires a callback with the result of f,
or an errback with a L{twisted.python.failure.Failure} if f throws
an exception.
def deferToThread(f, *args, **kwargs):
    '\n    Run a function in a thread and return the result as a Deferred.\n\n    @param f: The function to call.\n    @param *args: positional arguments to pass to f.\n    @param **kwargs: keyword arguments to pass to f.\n\n    @return: A Deferred which fires a callback with the result of f,\n    or an errback with a L{twisted.python.failure.Failure} if f throws\n    an exception.\n    '
    from twisted.internet import reactor
    return deferToThreadPool(reactor, reactor.getThreadPool(), f, *args, **kwargs)