feat: success callback + success_log for post-retry recovery - #662
Open
MohammedAnasNathani wants to merge 3 commits into
Open
feat: success callback + success_log for post-retry recovery#662MohammedAnasNathani wants to merge 3 commits into
MohammedAnasNathani wants to merge 3 commits into
Conversation
``after`` only runs on failed attempts that may be retried, so there was no first-class way to log "retry_success" when a call finally works. Add optional ``success=`` on Retrying / AsyncRetrying / @Retry, fired only on a clean terminal outcome. Ship ``success_log`` (default: only if attempt_number > 1) and document the distinction from ``after`` / after_log.
Mechanical reordering required for green CI under current ruff.
Runtime already accepted the kwarg via **dkw; overloads omitted it so mypy rejected tests and user code with call-overload.
jd
requested changes
Jul 31, 2026
| self, | ||
| sleep: t.Callable[ | ||
| [int | float], None | t.Awaitable[None] | ||
| [int | float], t.Awaitable[None] | None |
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.
Summary
Fixes the long-standing gap behind #531 / SO: people wire
after=expecting a “retry_success” log, butafteronly runs on failed attempts that may still be retried.API
beforeafterbefore_sleepsuccess(new)success_log(logger, level, only_if_retried=True)— built-in helper for the common “log recovery only” caseBaseRetrying,AsyncRetrying, and@retry(kwargs pass-through)aftersemanticsTests
successwith finalattempt_numbersuccessnever calledafterstill only on failed attemptssuccess_logrespectsonly_if_retriedLocal: 174 passed (tornado not installed in this env; CI has it)
Docs
index.rstdocuments theaftervssuccessdistinction with a short example.Closes #531