🪲 BUG-#143: Fix retry=0 causing zero execution attempts - #192
Merged
Conversation
Fixes #143 — the retry loop used range(1, self.retry + 1), so passing retry=0 produced an empty range and the task never ran at all. Wrap with max(1, self.retry) so the loop always executes at least one attempt regardless of the retry value.
The raise guard previously compared attempt == self.retry, which is always False when retry=0 (attempt is 1 after max(1, 0)). This caused failing tasks with retry=0 to silently return None instead of raising. Extract the clamped bound into max_attempts and use it in both the range() and the raise guard. Also adds test_retry_zero_raises_on_failure per review feedback.
fix: ensure retry=0 executes the task exactly once
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
max_attempts = max(1, self.retry)and use it in both the loop range and the raise guard, ensuringretry=0executes exactly once and raises on failureretry=0happy path and failure pathMotivation and Context
With
retry=0,range(1, 0+1)produces an empty range — the task never executes and returnsNonesilently. Additionally, the raise guardif attempt == self.retrycompared1 == 0which is alwaysFalse, silently swallowing exceptions.This PR resolves the conflict from PR #159 by combining
max_attempts(from #159) withfrom None(already in develop from PR #157).Closes #143
Types of changes
Checklist