def deferToThread(f, *args, **kwargs):
 from twisted.internet import reactor
 return deferToThreadPool(reactor, reactor.getThreadPool(), f, *args, **kwargs)

def deferToThread ( f , * args , ** kwargs ) : 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 .