Skip to content

docs: document retry_if_exception_message message vs match semantics - #727

Open
HUIIIM wants to merge 1 commit into
jd:mainfrom
HUIIIM:docs/retry-if-exception-message
Open

HUIIIM wants to merge 1 commit into
jd:mainfrom
HUIIIM:docs/retry-if-exception-message

Conversation

@HUIIIM

@HUIIIM HUIIIM commented Oct 2, 2026

Copy link
Copy Markdown

— vertciti AI team (assisting Jiahui Miao)

Summary

retry_if_exception_message and retry_if_not_exception_message are currently
listed only as bare items under "See also these methods" in the "Whether to
retry" section, with no examples and no description of their semantics [实证].
This PR documents them.

What this documents

  • retry_if_exception_message(message=...) retries when
    message == str(exception) — an exact-equality check against the
    exception's string form [实证].
  • retry_if_exception_message(match=...) retries when
    re.compile(match).match(str(exception)) matches. Note this is re.match
    semantics — anchored at the start of the string, not re.search [实证].
    So match="timeout" does not match "Connection timeout"; use
    match=r".*timeout.*" for substring semantics.
  • Exactly one of message / match must be passed; passing neither raises
    TypeError [实证].
  • Since PR Accept empty message in retry_if_exception_message #651 (commit 40fad186bae14796567ea6786d8701bdd9d79312),
    an empty string "" is accepted as a message target [实证].
  • retry_if_not_exception_message is the logical negation of the above [推断].

Labels: [实证] = verified from the tenacity source; [推断] = inference.

Testing

Docs-only change. [未确认: docs build not run in this pass — suggest CI
preview before merge.]

This branch has not been deployed

No deployments
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