Permalink
Browse files

take care of invalid redis servers params

  • Loading branch information...
salimane committed Oct 5, 2012
1 parent 73dbef1 commit 7bd7c60936603e668c985614dff0f68833dca656
Showing with 2 additions and 1 deletion.
  1. +2 −1 rediscluster/cluster_client.py
@@ -91,6 +91,7 @@ def __init__(self, cluster={}, db=0):
self.redises = {}
#connect to all servers
for alias, server in iteritems(cluster['nodes']):
+ info = {}
try:
self.__redis = redis.StrictRedis(db=db, **server)
info = self.__redis.info()
@@ -101,7 +102,7 @@ def __init__(self, cluster={}, db=0):
#if node is slave and is down, replace its connection with its master's
try:
ms = [k for k, v in iteritems(cluster['master_of'])
- if v == alias and (info['role'] == 'slave' or cluster['nodes'][k] == cluster['nodes'][v])][0]
+ if v == alias and (('role' in info and info['role'] == 'slave') or cluster['nodes'][k] == cluster['nodes'][v])][0]
except IndexError:
ms = None

0 comments on commit 7bd7c60

Please sign in to comment.