4242from redis .retry import Retry
4343from redis .utils import (
4444 HIREDIS_AVAILABLE ,
45+ deprecated_args ,
4546 dict_merge ,
4647 list_keys_to_dict ,
4748 merge_result ,
@@ -54,10 +55,13 @@ def get_node_name(host: str, port: Union[str, int]) -> str:
5455 return f"{ host } :{ port } "
5556
5657
58+ @deprecated_args (
59+ allowed_args = ["redis_node" ],
60+ reason = "Use get_connection(redis_node) instead" ,
61+ version = "5.0.3" ,
62+ )
5763def get_connection (redis_node , * args , ** options ):
58- return redis_node .connection or redis_node .connection_pool .get_connection (
59- args [0 ], ** options
60- )
64+ return redis_node .connection or redis_node .connection_pool .get_connection ()
6165
6266
6367def parse_scan_result (command , res , ** options ):
@@ -1173,7 +1177,7 @@ def _execute_command(self, target_node, *args, **kwargs):
11731177 moved = False
11741178
11751179 redis_node = self .get_redis_connection (target_node )
1176- connection = get_connection (redis_node , * args , ** kwargs )
1180+ connection = get_connection (redis_node )
11771181 if asking :
11781182 connection .send_command ("ASKING" )
11791183 redis_node .parse_response (connection , "ASKING" , ** kwargs )
@@ -1652,7 +1656,7 @@ def initialize(self):
16521656 if len (disagreements ) > 5 :
16531657 raise RedisClusterException (
16541658 f"startup_nodes could not agree on a valid "
1655- f' slots cache: { ", " .join (disagreements )} '
1659+ f" slots cache: { ', ' .join (disagreements )} "
16561660 )
16571661
16581662 fully_covered = self .check_slots_coverage (tmp_slots )
@@ -1850,9 +1854,7 @@ def execute_command(self, *args):
18501854 self .node = node
18511855 redis_connection = self .cluster .get_redis_connection (node )
18521856 self .connection_pool = redis_connection .connection_pool
1853- self .connection = self .connection_pool .get_connection (
1854- "pubsub" , self .shard_hint
1855- )
1857+ self .connection = self .connection_pool .get_connection ()
18561858 # register a callback that re-subscribes to any channels we
18571859 # were listening to when we were disconnected
18581860 self .connection .register_connect_callback (self .on_connect )
@@ -2073,8 +2075,7 @@ def annotate_exception(self, exception, number, command):
20732075 """
20742076 cmd = " " .join (map (safe_str , command ))
20752077 msg = (
2076- f"Command # { number } ({ cmd } ) of pipeline "
2077- f"caused error: { exception .args [0 ]} "
2078+ f"Command # { number } ({ cmd } ) of pipeline caused error: { exception .args [0 ]} "
20782079 )
20792080 exception .args = (msg ,) + exception .args [1 :]
20802081
@@ -2212,8 +2213,8 @@ def _send_cluster_commands(
22122213 if node_name not in nodes :
22132214 redis_node = self .get_redis_connection (node )
22142215 try :
2215- connection = get_connection (redis_node , c . args )
2216- except ConnectionError :
2216+ connection = get_connection (redis_node )
2217+ except ( ConnectionError , TimeoutError ) :
22172218 for n in nodes .values ():
22182219 n .connection_pool .release (n .connection )
22192220 # Connection retries are being handled in the node's
0 commit comments