def callInThreadPool(fun, *args, **kwargs):
 if isInThreadPool():
  fun(*args, **kwargs)
 else:
  reactor.callFromThread(reactor.callInThread, fun, *args, **kwargs)

def callInThreadPool ( fun , * args , ** kwargs ) : if isInThreadPool ( ) : fun ( * args , ** kwargs ) else : reactor . callFromThread ( reactor . callInThread , fun , * args , ** kwargs )
calls fun in the reactors thread pool .