@@ -755,7 +755,6 @@ class ClusterNode:
755
755
"""
756
756
757
757
__slots__ = (
758
- "_command_stack" ,
759
758
"_connections" ,
760
759
"_free" ,
761
760
"connection_class" ,
@@ -796,7 +795,6 @@ def __init__(
796
795
797
796
self ._connections : List [Connection ] = []
798
797
self ._free : Deque [Connection ] = collections .deque (maxlen = self .max_connections )
799
- self ._command_stack : List ["PipelineCommand" ] = []
800
798
801
799
def __repr__ (self ) -> str :
802
800
return (
@@ -887,18 +885,18 @@ async def execute_command(self, *args: Any, **kwargs: Any) -> Any:
887
885
# Release connection
888
886
self ._free .append (connection )
889
887
890
- async def execute_pipeline (self ) -> bool :
888
+ async def execute_pipeline (self , commands : List [ "PipelineCommand" ] ) -> bool :
891
889
# Acquire connection
892
890
connection = self .acquire_connection ()
893
891
894
892
# Execute command
895
893
await connection .send_packed_command (
896
- connection .pack_commands (cmd .args for cmd in self . _command_stack ), False
894
+ connection .pack_commands (cmd .args for cmd in commands ), False
897
895
)
898
896
899
897
# Read responses
900
898
ret = False
901
- for cmd in self . _command_stack :
899
+ for cmd in commands :
902
900
try :
903
901
cmd .result = await self .parse_response (
904
902
connection , cmd .args [0 ], ** cmd .kwargs
@@ -1365,12 +1363,14 @@ async def _execute(
1365
1363
1366
1364
node = target_nodes [0 ]
1367
1365
if node .name not in nodes :
1368
- nodes [node .name ] = node
1369
- node ._command_stack = []
1370
- node ._command_stack .append (cmd )
1366
+ nodes [node .name ] = (node , [])
1367
+ nodes [node .name ][1 ].append (cmd )
1371
1368
1372
1369
errors = await asyncio .gather (
1373
- * (asyncio .ensure_future (node .execute_pipeline ()) for node in nodes .values ())
1370
+ * (
1371
+ asyncio .ensure_future (node [0 ].execute_pipeline (node [1 ]))
1372
+ for node in nodes .values ()
1373
+ )
1374
1374
)
1375
1375
1376
1376
if any (errors ):
0 commit comments