fix: CancelledError propagation (#529) and empty string in retry_if_exception_message (#598)#638
Open
fix: CancelledError propagation (#529) and empty string in retry_if_exception_message (#598)#638
Conversation
added 2 commits
March 26, 2026 02:54
These three additions address cloud API rate limiting patterns not covered by existing tenacity strategies: - wait_retry_after: reads HTTP Retry-After header from 429 responses, falls back to exponential jitter if header absent. - wait_rpm_budget: shared RPM counter per provider key, triggers wait when 85% of the rate limit is reached. Useful for async tasks sharing the same API quota (Groq, Gemini, OpenRouter free tier). - retry_if_rate_limited: predicate detecting litellm.RateLimitError, httpx.HTTPStatusError(429), and string patterns for broader compat. Closes: rate-limit awareness gap for LLM API consumers.
…rror propagation fix jd#598: retry_if_exception_message(message='') raised TypeError because 'if message' treats empty string as falsy. Changed to 'is not None' checks. fix jd#529: retry_if_not_exception_type was retrying asyncio.CancelledError, defeating task cancellation semantics. CancelledError now always propagates.
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.
Fixes #529
Fixes #598
Fix #598 —
retry_if_exception_message(message='')raises TypeErrorThe constructor used Python truthiness checks (
if message) instead ofis not None. An empty string''is falsy, causing a TypeError.Changed to explicit
is not Nonechecks throughout.Fix #529 —
asyncio.CancelledErrorswallowed byretry_if_not_exception_typeretry_if_not_exception_typewas retryingasyncio.CancelledError, defeating task cancellation semantics. This fix makesCancelledErroralways propagate, regardless ofexception_types.Both fixes include no behavior change for the normal (non-edge) cases, confirmed by the existing 153-test suite passing.