def METHOD_NAME() -> T:
    # in case of exception let's fail fast and do not execute the function
    if self._exceptions.get(task.key) is None:
        try:
            return task()
        except Exception as e:
            # only store the first exception if we should fail on first future
            if self._exceptions.get(task.key) is None:
                self._exceptions[task.key] = e
            raise e
    else:
        raise CancelOnFirstError(
            "Exception happened in another thread. Do not start work."
        ) from self._exceptions[task.key]