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:
Tamil Adhavan S K 2026-06-24 22:10:38 +00:00 • committed by adhavan
parent 9e7ba65759
commit 879ed17db1

View file

@ -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: