diff --git a/rediscluster/client.py b/rediscluster/client.py index cb8f59de..413a7972 100644 --- a/rediscluster/client.py +++ b/rediscluster/client.py @@ -442,7 +442,7 @@ def pubsub(self, **kwargs): """ return ClusterPubSub(self.connection_pool, **kwargs) - def pipeline(self, transaction=None, shard_hint=None): + def pipeline(self, transaction=None, shard_hint=None, read_from_replicas=False): """ Cluster impl: Pipelines do not work in cluster mode the same way they do in normal mode. @@ -461,6 +461,7 @@ def pipeline(self, transaction=None, shard_hint=None): result_callbacks=self.result_callbacks, response_callbacks=self.response_callbacks, cluster_down_retry_attempts=self.cluster_down_retry_attempts, + read_from_replicas=read_from_replicas, ) def transaction(self, *args, **kwargs): diff --git a/rediscluster/pipeline.py b/rediscluster/pipeline.py index 1b7065fc..4d2272ee 100644 --- a/rediscluster/pipeline.py +++ b/rediscluster/pipeline.py @@ -194,7 +194,7 @@ def _send_cluster_commands(self, stack, raise_on_error=True, allow_redirections= # refer to our internal node -> slot table that tells us where a given # command should route to. slot = self._determine_slot(*c.args) - node = self.connection_pool.get_node_by_slot(slot) + node = self.connection_pool.get_node_by_slot(slot, self.read_from_replicas) # little hack to make sure the node name is populated. probably could clean this up. self.connection_pool.nodes.set_node_name(node)