From 5a926cfb86af1861c9967171c340da5ea211c4c6 Mon Sep 17 00:00:00 2001 From: "Emmanuel I. Obi" Date: Mon, 17 Oct 2022 09:22:04 -0500 Subject: [PATCH] RetryPolicy delay proceeds performance of wrapped Action (#145) --- actionpack/actions/retry_policy.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/actionpack/actions/retry_policy.py b/actionpack/actions/retry_policy.py index 6d5f3ca..1e21774 100644 --- a/actionpack/actions/retry_policy.py +++ b/actionpack/actions/retry_policy.py @@ -39,14 +39,14 @@ def validate(self) -> RetryPolicy: def enact(self, with_delay: int = 0, counter: int = -1) -> Outcome: for _tally in tally(1 + self.max_retries): - sleep(with_delay) + attempt = self.action.perform() counter += _tally self.retries = counter - retry = self.action.perform() if self.should_record: - self.attempts.append(retry) - if retry.successful: - return retry.value + self.attempts.append(attempt) + if attempt.successful: + return attempt.value + sleep(with_delay) raise RetryPolicy.Expired(f'Max retries exceeded: {self.max_retries}.')