From 879ed17db1a7d23ad15572673b2eacf3404c2949 Mon Sep 17 00:00:00 2001 From: Tamil Adhavan S K <99407456+adhavan18@users.noreply.github.com> Date: Wed, 24 Jun 2026 22:10:38 +0000 Subject: [PATCH] fix(caching): guard against None async_redis_conn_pool in RedisCache.disconnect Fixes #31206 When REDIS_CLUSTER_NODES is set, get_redis_connection_pool() returns None because the cluster mode path exits early. This causes RedisCache.__init__ to store self.async_redis_conn_pool = None. At shutdown, disconnect() then crashes with AttributeError: 'NoneType' has no attribute 'disconnect'. Add a None guard before calling .disconnect() on the connection pool. --- litellm/caching/redis_cache.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litellm/caching/redis_cache.py b/litellm/caching/redis_cache.py index dd1c152a421..4263a41b47d 100644 --- a/litellm/caching/redis_cache.py +++ b/litellm/caching/redis_cache.py @@ -1270,7 +1270,8 @@ class RedisCache(BaseCache): self.redis_client.flushall() async def disconnect(self): - await self.async_redis_conn_pool.disconnect(inuse_connections=True) + if self.async_redis_conn_pool is not None: + await self.async_redis_conn_pool.disconnect(inuse_connections=True) try: self.redis_client.close() except Exception as e: