Skip to content

Commit

Permalink
RetryPolicy delay proceeds performance of wrapped Action (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
withtwoemms committed Oct 17, 2022
1 parent dbfa858 commit 5a926cf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions actionpack/actions/retry_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}.')

Expand Down

0 comments on commit 5a926cf

Please sign in to comment.