Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
Add sleep to TryAgainError and change the exception raised when TTL i…
Browse files Browse the repository at this point in the history
…s exhausted to make it easier to understand what error it is.
  • Loading branch information
Grokzen committed Jul 14, 2015
1 parent 44640c5 commit a943d84
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rediscluster/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,15 @@ def execute_command(self, *args, **kwargs):
self.connection_pool.nodes.slots[e.slot_id] = node
redirect_addr = "%s:%s" % (e.host, e.port)
except ClusterParser.TryAgainError as e:
print("TODO: TRY AGAIN ERROR...")
if ttl < self.COMMAND_TTL / 2:
time.sleep(0.05)
except ClusterParser.AskError as e:
node = self.connection_pool.nodes.set_node(e.host, e.port, server_type='master')
redirect_addr, asking = "%s:%s" % (e.host, e.port), True
finally:
self.connection_pool.release(r)

raise RedisClusterException("Too many Cluster redirections")
raise ClusterParser.ClusterError('TTL exhausted.')

def _execute_command_on_nodes(self, nodes, *args, **kwargs):
command = args[0]
Expand Down

0 comments on commit a943d84

Please sign in to comment.