def result(self):
    """If the task has completed successfully then holds the
    return value of the task, otherwise raises AttributeError.
    """
    if self.succeeded:
      task = self
      while isinstance(task._result, Task):
        task = task._result
      return task._result
    else:
      raise AttributeError("result only available on successful tasks")