Skip to content

Commit

Permalink
opt: optimize code proceed single node slots (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoneGG authored Jan 19, 2018
1 parent 51b6ec5 commit b5f81d8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions aredis/nodemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,10 @@ async def initialize(self):
# Fix it to the host in startup_nodes
if (len(cluster_slots) == 1
and len(self.startup_nodes) == 1):
single_node_slots = cluster_slots.pop((0, self.RedisClusterHashSlots - 1))[0]
if single_node_slots and len(single_node_slots['host']) == 0:
single_node_slots = cluster_slots.get((0, self.RedisClusterHashSlots - 1))[0]
if len(single_node_slots['host']) == 0:
single_node_slots['host'] = self.startup_nodes[0]['host']
single_node_slots['server_type'] = 'master'
cluster_slots = {(0, self.RedisClusterHashSlots - 1): [single_node_slots]}

# No need to decode response because StrictRedis should handle that for us...
for min_slot, max_slot in cluster_slots:
Expand Down

0 comments on commit b5f81d8

Please sign in to comment.