The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(redis): drop a connect func the async cluster client cannot accept
mateo-berri308c906cdd94
diff --git a/litellm/_redis.py b/litellm/_redis.pyindex ebbc191dfec..8e67bc66e5f 100644--- a/litellm/_redis.py+++ b/litellm/_redis.py@@ -648,6 +648,7 @@ def get_redis_async_client(for item in redis_kwargs["startup_nodes"]:new_startup_nodes.append(ClusterNode(**item))cluster_kwargs.pop("startup_nodes", None)+ cluster_kwargs.pop("redis_connect_func", None)# Default to a periodic health check + TCP keepalive so a connection silently dropped# by a cluster restart (e.g. ElastiCache Serverless maintenance) is revalidated anddiff --git a/tests/test_litellm/test_redis.py b/tests/test_litellm/test_redis.pyindex 5d03eb6d660..d706c40767b 100644--- a/tests/test_litellm/test_redis.py+++ b/tests/test_litellm/test_redis.py@@ -1005,3 +1005,22 @@ def test_async_url_keeps_a_coroutine_connect_func(build_pool):assert pool.connection_kwargs["redis_connect_func"] is connectassert "credential_provider" not in pool.connection_kwargs+++def test_async_cluster_drops_a_connect_func_it_cannot_pass_on():+ """redis-py's async RedisCluster has no redis_connect_func parameter, so a connect func that+ is not translated into a credential provider has to be dropped rather than forwarded.+ """++ async def connect(connection):+ return None++ redis_kwargs = {+ "startup_nodes": [{"host": "cluster-node", "port": 6379}],+ "redis_connect_func": connect,+ }++ with patch("litellm._redis._get_redis_client_logic", return_value=redis_kwargs):+ client = get_redis_async_client()++ assert isinstance(client, async_redis.RedisCluster)