Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add exceptiongroup support to retry_if_exception #501

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jakkdl
Copy link
Contributor

@jakkdl jakkdl commented Oct 31, 2024

This makes tenacity transparently handle any exceptions wrapped inside an ExceptionGroup, so it'll handle a ValueError() the same as ExceptionGroup("...", [ValueError()]).
If you want it to be more explicit it could be added as a parameter "allow_group".

I have not implemented it for retry_if_exception_cause_type as it gets quite messy conceptually: "retry if any of the causes of any of the raised exceptions, recursively checked both on any exceptiongroup and their containing exceptions, is of one or more types". This doesn't sound like something any sane person would ever want.

I have not implemented retry_if[_not]_exception_message. This one is less weird and I can probably just do it as "retry if the messages of all the exceptions in a group matches" and ignore the exceptiongroup message, but that's still somewhat sketchy.

When reading the tests I also found a random unused _retryable helper. I'm guessing I can just remove it?

Since #480 is not merged I also quickly added py313 to tox & CI

TODO:

  1. write changelog
  2. write docs

@Zac-HD

Copy link
Contributor

mergify bot commented Oct 31, 2024

⚠️ No release notes detected. Please make sure to use reno to add a changelog entry.

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