Skip to content

Retries do no work with asyncio #2179

Closed
@elemoine

Description

@elemoine

We use redis.asyncio.StrictRedis and redis.asyncio.BlockingConnectionPool, with some specific Retry configuration:

from redis.asyncio import BlockingConnectionPool, StrictClient
from redis.exceptions import ConnectionError, TimeoutError
from redis.asyncio.retry import Retry

errors = (ConnectionError, TimeoutError)
retry = Retry(backoff=backoff, retries=retries, supported_errors=errors)
pool = BlockingConnectionPool(retry=retry, retry_on_timeout=True)
client = StrictClient(connection_pool=pool)

And that doesn't work as expected! There are no retries at all on ConnectionError exceptions!

Here's what happens:

When executing a command, an error handler is passed to call_with_retry. That error handler is the _disconnect_raise function, which re-raises the exception if that exception is not a TimeoutError. Meaning that, in case of a ConnectionError, call_with_retry will raise and exit before having a chance to retry the operation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions