Skip to content

Retry on exception not working #114

@rChaoz

Description

@rChaoz

Issue

The docs says that:

exceptions: Iterable[type[Exception]] | None = None, # On which exceptions we should retry, by default on all

So, it's expected that it retries on exceptions by default. But, it doesn't, as None is transformed into an empty set:

if exceptions is None:
exceptions = set()
self.exceptions: Iterable[type[Exception]] = exceptions

Which then causes the retry condition to always fail:

is_exc_valid = any(isinstance(e, exc) for exc in self._retry_options.exceptions)

as any(<empty>) always returns False.

Solution

Either this is a documentation issue (should mention that, by default, doesn't retry on exceptions), or the documentation is right, in which case the default should be changed from set() to {Exception}.

Workaround

Set exceptions={Exception}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions