Use default single-retry for any RedisError

Using the default Retry means that async and sync clients get the appropriate type of Retry
This commit is contained in:
Masen Furer 2025-01-06 16:19:38 -08:00
parent 7419efeae3
commit 6aabb57cf3
No known key found for this signature in database
GPG Key ID: B0008AD22B3B3A95

View File

@ -21,7 +21,7 @@ import zipfile
from datetime import datetime
from pathlib import Path
from types import ModuleType
from typing import Any, Callable, List, Optional
from typing import Callable, List, Optional
import httpx
import typer
@ -29,9 +29,7 @@ from alembic.util.exc import CommandError
from packaging import version
from redis import Redis as RedisSync
from redis.asyncio import Redis
from redis.backoff import ExponentialBackoff
from redis.exceptions import RedisError
from redis.retry import Retry
from reflex import constants, model
from reflex.compiler import templates
@ -329,13 +327,6 @@ def get_compiled_app(reload: bool = False, export: bool = False) -> ModuleType:
return app_module
def _get_common_redis_kwargs() -> dict[str, Any]:
return {
"retry": Retry(ExponentialBackoff(), 3),
"retry_on_error": [RedisError],
}
def get_redis() -> Redis | None:
"""Get the asynchronous redis client.
@ -345,7 +336,7 @@ def get_redis() -> Redis | None:
if (redis_url := parse_redis_url()) is not None:
return Redis.from_url(
redis_url,
**_get_common_redis_kwargs(),
retry_on_error=[RedisError],
)
return None
@ -359,7 +350,7 @@ def get_redis_sync() -> RedisSync | None:
if (redis_url := parse_redis_url()) is not None:
return RedisSync.from_url(
redis_url,
**_get_common_redis_kwargs(),
retry_on_error=[RedisError],
)
return None