mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-29 01:42:19 +00:00
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.
This commit is contained in:
parent
9e7ba65759
commit
879ed17db1
1 changed files with 2 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue