code: def _function_handler(function, args, kwargs, future):
      
      future.set_running_or_notify_cancel()
  
      try:
          result = function(*args, **kwargs)
      except BaseException as error:
          error.traceback = format_exc()
          future.set_exception(error)
      else:
          future.set_result(result)
docs: Runs the actual function in separate thread and returns its result.