The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
refactor(redis): drop the narrative docstrings on the breaker helper and its tests
mateo-berric7d3a6a1d46d
diff --git a/litellm/caching/redis_cache.py b/litellm/caching/redis_cache.pyindex d938b94df43..6b93529e456 100644--- a/litellm/caching/redis_cache.py+++ b/litellm/caching/redis_cache.py@@ -393,17 +393,12 @@ def _record_swallowed_redis_failure(breaker: RedisCircuitBreaker, exc: BaseExcepclass RedisCircuitBreakerOpenError(Exception):- """Raised in place of a Redis call while the circuit breaker is open."""+ passdef log_redis_failure(logger: logging.Logger, level: int, message: str, exc: BaseException, with_traceback: bool = False) -> None:- """Log a Redis failure the caller is about to swallow.-- An open breaker refuses every call until Redis recovers and announced itself once when it- opened, so the calls it refuses are logged at debug instead of once per request at ``level``.- """if isinstance(exc, RedisCircuitBreakerOpenError):logger.debug("%s: %s", message, exc)returndiff --git a/tests/test_litellm/caching/test_dual_cache.py b/tests/test_litellm/caching/test_dual_cache.pyindex b0c17507adb..eae8bbfdaff 100644--- a/tests/test_litellm/caching/test_dual_cache.py+++ b/tests/test_litellm/caching/test_dual_cache.py@@ -581,8 +581,6 @@ async def test_dual_cache_late_attach_redis_wires_writes_and_ttl_async():class _OpenBreakerRedis:- """A RedisCache whose breaker is open, so every guarded call is refused before it starts."""-def __init__(self) -> None:from litellm.caching.redis_cache import RedisCircuitBreaker@@ -639,9 +637,6 @@ class _OpenBreakerRedis:ids=["get", "batch_get", "set", "set_pipeline", "increment_pipeline", "increment"],)async def test_an_open_circuit_breaker_is_not_an_error_per_request(caplog, call):- """While the breaker is open every request is refused by design, and the breaker already- said so once when it opened; logging each refusal as an ERROR traceback was the storm that- pinned every worker's CPU during a Redis latency blip."""cache = DualCache(in_memory_cache=InMemoryCache(), redis_cache=_OpenBreakerRedis()) # pyright: ignore[reportArgumentType] # duck-typed Redis doublecaplog.clear()diff --git a/tests/test_litellm/caching/test_redis_cache.py b/tests/test_litellm/caching/test_redis_cache.pyindex b9d965a8942..bcaa58c9c40 100644--- a/tests/test_litellm/caching/test_redis_cache.py+++ b/tests/test_litellm/caching/test_redis_cache.py@@ -1016,11 +1016,6 @@ async def test_breaker_metrics_track_state_and_failure_class():def test_sync_guard_counts_a_timeout_as_a_timeout():- """A sync Redis timeout must wait out the timeout-only min duration exactly like the async guard.-- Recording it as a hard connectivity failure opened the breaker on the fifth slow reply,- which is how a latency blip took the shared cache out for every worker.- """from redis.exceptions import TimeoutError as RedisTimeoutErrorfrom litellm.caching.redis_cache import RedisCircuitBreaker, _run_under_circuit_breaker_sync