Skip to content

Commit 45d8693

Browse files
authored
Send ssubscribe one by one for redis cluster (#26)
1 parent e24cd78 commit 45d8693

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

redis/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,8 @@ def ssubscribe(self, *args, target_node=None, **kwargs):
16721672
args = list_or_args(args[0], args[1:])
16731673
new_s_channels = dict.fromkeys(args)
16741674
new_s_channels.update(kwargs)
1675-
ret_val = self.execute_command("SSUBSCRIBE", *new_s_channels.keys())
1675+
for channel in new_s_channels: # We should send ssubscribe one by one on redis cluster to prevent CROSSSLOT error
1676+
self.execute_command("SSUBSCRIBE", channel)
16761677
# update the s_channels dict AFTER we send the command. we don't want to
16771678
# subscribe twice to these channels, once for the command and again
16781679
# for the reconnection.
@@ -1684,7 +1685,6 @@ def ssubscribe(self, *args, target_node=None, **kwargs):
16841685
# Clear the health check counter
16851686
self.health_check_response_counter = 0
16861687
self.pending_unsubscribe_shard_channels.difference_update(new_s_channels)
1687-
return ret_val
16881688

16891689
def sunsubscribe(self, *args, target_node=None):
16901690
"""

0 commit comments

Comments
 (0)