mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
refactor(redis): drop the narrative docstrings on the breaker helper and its tests
This commit is contained in:
parent
d62493a779
commit
c7d3a6a1d4
3 changed files with 1 additions and 16 deletions
|
|
@ -393,17 +393,12 @@ def _record_swallowed_redis_failure(breaker: RedisCircuitBreaker, exc: BaseExcep
|
|||
|
||||
|
||||
class RedisCircuitBreakerOpenError(Exception):
|
||||
"""Raised in place of a Redis call while the circuit breaker is open."""
|
||||
pass
|
||||
|
||||
|
||||
def 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)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -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 double
|
||||
caplog.clear()
|
||||
|
||||
|
|
|
|||
|
|
@ -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 RedisTimeoutError
|
||||
|
||||
from litellm.caching.redis_cache import RedisCircuitBreaker, _run_under_circuit_breaker_sync
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue