From 809e3cbd75e7a97f24669bd323ff027a94f549f5 Mon Sep 17 00:00:00 2001 From: mateo Date: Sat, 31 Oct 2026 03:40:38 +0000 Subject: [PATCH] fix(scheduler): defer optional Redis exception import Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/scheduler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litellm/scheduler.py b/litellm/scheduler.py index 77b5bb724c7..48be61283df 100644 --- a/litellm/scheduler.py +++ b/litellm/scheduler.py @@ -8,7 +8,6 @@ from typing import Final, TypeAlias from typing import Protocol as _Protocol from pydantic import TypeAdapter -from redis.exceptions import RedisError as _RedisError from litellm import print_verbose from litellm._internal_context import with_service_target @@ -45,6 +44,8 @@ class _QueueCache(_Protocol): async def _read_queue(cache: _QueueCache, redis_cache: _QueueCache | None, key: str) -> object: if redis_cache is None: return await cache.async_get_cache(key=key, local_only=True) + from redis.exceptions import RedisError as _RedisError + try: response: Final = await redis_cache.async_get_cache(key=key, raise_on_error=True) except (_RedisError, _RedisCircuitBreakerOpenError) as error: