def deferToThreadInReactor(reactor, f, *args, **kwargs):
 d = defer.Deferred()
 reactor.callInThread(_putResultInDeferred, reactor, d, f, args, kwargs)
 return d

def deferToThreadInReactor ( reactor , f , * args , ** kwargs ) : d = defer . Deferred ( ) reactor . callInThread ( _putResultInDeferred , reactor , d , f , args , kwargs ) return d
run function in thread and return result as deferred .