Skip to content

Commit

Permalink
Use password from redis+sentinel uri
Browse files Browse the repository at this point in the history
If a password is provided in the redis+sentinel uri
pass it on to the Sentinel object.
  • Loading branch information
alisaifee committed Dec 18, 2015
1 parent 3151af3 commit 2012d2a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions limits/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,10 @@ def __init__(self, uri, **options):

parsed = urllib.parse.urlparse(uri)
sentinel_configuration = []
for loc in parsed.netloc.split(","):
password = None
if parsed.password:
password = parsed.password
for loc in parsed.netloc[parsed.netloc.find("@")+1:].split(","):
host, port = loc.split(":")
sentinel_configuration.append((host, int(port)))
self.service_name = (
Expand All @@ -408,7 +411,8 @@ def __init__(self, uri, **options):
raise ConfigurationError("'service_name' not provided")
self.sentinel = get_dependency("redis.sentinel").Sentinel(
sentinel_configuration,
socket_timeout=options.get("socket_timeout", 0.2)
socket_timeout=options.get("socket_timeout", 0.2),
password=password
)
self.initialize_storage()
super(RedisSentinelStorage, self).__init__()
Expand Down

0 comments on commit 2012d2a

Please sign in to comment.