Skip to content

Commit 0d8b0a7

Browse files
async_cluster: fix args for startup_nodes
1 parent cdcae0d commit 0d8b0a7

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

redis/asyncio/cluster.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,14 @@ def __init__(
302302
kwargs["response_callbacks"] = self.__class__.RESPONSE_CALLBACKS.copy()
303303
self.connection_kwargs = kwargs
304304

305-
if not startup_nodes:
305+
if startup_nodes:
306+
passed_nodes = []
307+
for node in startup_nodes:
308+
passed_nodes.append(
309+
ClusterNode(node.host, node.port, **self.connection_kwargs)
310+
)
311+
startup_nodes = passed_nodes
312+
else:
306313
startup_nodes = []
307314
if host and port:
308315
startup_nodes.append(ClusterNode(host, port, **self.connection_kwargs))
@@ -1063,6 +1070,7 @@ async def initialize(self) -> None:
10631070
fully_covered = False
10641071
exception = None
10651072
for startup_node in self.startup_nodes.values():
1073+
tmp_nodes_cache[startup_node.name] = startup_node
10661074
try:
10671075
# Make sure cluster mode is enabled on this node
10681076
if not (await startup_node.execute_command("INFO")).get(

tests/test_asyncio/test_cluster.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,18 @@ async def test_startup_nodes(self) -> None:
239239

240240
await cluster.close()
241241

242-
startup_nodes = [ClusterNode("127.0.0.1", 16379)]
243-
async with RedisCluster(startup_nodes=startup_nodes) as rc:
242+
startup_node = ClusterNode("127.0.0.1", 16379)
243+
async with RedisCluster(startup_nodes=[startup_node], client_name="test") as rc:
244244
assert await rc.set("A", 1)
245245
assert await rc.get("A") == b"1"
246+
assert all(
247+
[
248+
name == "test"
249+
for name in (
250+
await rc.client_getname(target_nodes=rc.ALL_NODES)
251+
).values()
252+
]
253+
)
246254

247255
async def test_empty_startup_nodes(self) -> None:
248256
"""

0 commit comments

Comments
 (0)