#NEWLINE# def deferToThread( f , * args , **kwargs ) : #NEWLINE# #INDENT# '\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    ' #NEWLINE# from twisted.internet import reactor #NEWLINE# return deferToThreadPool ( reactor , reactor . getThreadPool ( ) , f , * f , ** kwargs )