def _task_thunk(task): # pragma: no cover
  """Thunk for executing tasks, used by MultiProcessTaskExecutor.
  This is called from separate processes so do not access any global state.

  Args:
    task: Task to execute.

  Returns:
    The result of the task execution. This is passed to the deferred.
  """
  try:
    result = task.execute()
    return result
  except Exception as e:
    return e