Skip to content

feat: add retry_unless_exception_cause_type (cycle-safe cause walk) - #663

Open
MohammedAnasNathani wants to merge 4 commits into
jd:mainfrom
MohammedAnasNathani:feat/retry-unless-exception-cause-type
Open

feat: add retry_unless_exception_cause_type (cycle-safe cause walk)#663
MohammedAnasNathani wants to merge 4 commits into
jd:mainfrom
MohammedAnasNathani:feat/retry-unless-exception-cause-type

Conversation

@MohammedAnasNathani

Copy link
Copy Markdown
Contributor

Summary

Implements #625retry_unless_exception_cause_type, the cause-chain mirror of retry_unless_exception_type / partner to retry_if_exception_cause_type.

Also hardens cause walking with a cycle-safe helper so raise e from e cannot hang the retry loop (#658).

API

@retry(retry=retry_unless_exception_cause_type(NameError), reraise=True)
def call():
    ...
  • Keep retrying while no matching type appears in the __cause__ chain
  • Stop (do not retry) when a matching cause is found
  • Successful outcomes follow the same convention as retry_unless_exception_type

Tests

  • Integration: stop immediately when cause is NameError
  • Unit: predicate true/false for OSError-vs-NameError causes
  • Cycle: self-referential __cause__ terminates

Closes #625
Related: #658

Implements jd#625 as the mirror of retry_if_exception_cause_type.
Factor a cycle-safe _cause_chain_contains helper so self-referential
__cause__ chains cannot hang the retry loop (jd#658).
Copilot AI review requested due to automatic review settings July 26, 2026 21:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@MohammedAnasNathani

Copy link
Copy Markdown
Contributor Author

Ready for review. Local: 170 tests pass (+ tornado skipped offline); CI green on 3.10–3.14 (check/lint/mypy). Implements #625 with cycle-safe cause walk (#658).

Comment thread tenacity/__init__.py
Comment on lines +280 to +282
| object
| None = _unset,
name: str | object | None = _unset,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just noise/churn AFAICT

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.

[FEATURE REQUEST] retry_unless_exception_cause_type

3 participants