From e0efa721e96e120d26d65f6880dc98c163140877 Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Wed, 15 May 2024 15:50:00 -0400 Subject: [PATCH] Return / raise even if complete --- src/controlflow/core/task.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controlflow/core/task.py b/src/controlflow/core/task.py index 74a60fed..b5fc333e 100644 --- a/src/controlflow/core/task.py +++ b/src/controlflow/core/task.py @@ -302,10 +302,10 @@ def run(self, max_iterations: int = NOTSET) -> T: ) self.run_once() counter += 1 - if self.is_successful(): - return self.result - elif self.is_failed(): - raise ValueError(f"{self.friendly_name()} failed: {self.error}") + if self.is_successful(): + return self.result + elif self.is_failed(): + raise ValueError(f"{self.friendly_name()} failed: {self.error}") @contextmanager def _context(self):