Skip to content

Respect enabled=False on the direct-call path#645

Open
greymoth-jp wants to merge 2 commits into
jd:mainfrom
greymoth-jp:fix/respect-enabled-false-in-direct-call
Open

Respect enabled=False on the direct-call path#645
greymoth-jp wants to merge 2 commits into
jd:mainfrom
greymoth-jp:fix/respect-enabled-false-in-direct-call

Conversation

@greymoth-jp

Copy link
Copy Markdown

Retrying(enabled=False)(fn) and AsyncRetrying(enabled=False)(fn) ignore enabled=False on the direct-call path — they run the full retry loop and wrap the original exception in RetryError, instead of calling the function once and propagating its exception.

PR #643 added the enabled=False short-circuit to the iterator protocols (__iter__/__aiter__/__anext__) but the direct-call protocol (__call__) was left behind, since iter() itself never consults enabled. The fix adds the same short-circuit at the top of each __call__ (awaiting coroutine callables for the async path).

Verified both ways: old runs the function 5× and raises RetryError (sync and async); fixed calls once and raises the original ValueError, matching the iterator/decorator paths. 154 existing tests green; +4 regression tests (which fail on the unfixed code) → 158 passed.

greymoth-jp and others added 2 commits June 26, 2026 16:10
`Retrying.__call__` and `AsyncRetrying.__call__` ignored the `enabled`
flag: calling a controller created with `enabled=False` still ran the
full retry loop, so a failing function was retried and the original
exception was wrapped in a `RetryError`.

This makes the direct-call protocol consistent with the decorator
(`@retry(enabled=False)`) and the iterator protocols
(`__iter__`/`__aiter__`, fixed in jd#643): with `enabled=False` the
function is executed exactly once and any exception propagates
unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant