def callInThread(func, *args):
      """Takes a blocking function an converts it into a deferred-valued 
      function running in a separate thread.
      """
      de = defer.Deferred()
      de.addCallback(func)
      reactor.callInThread(de.callback, *args)
      return de
Takes a blocking function an converts it into a deferred-valued 
      function running in a separate thread.
      
recipes/Python/439358_Twisted_blocking_functions_deferred/recipe-439358.py