diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2014-05-06 13:00:48 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2014-05-06 13:00:48 -0700 |
commit | 7666f4ffaedb5acf91419110e0b2d66d35f467b4 (patch) | |
tree | 46ee697cdb2360a4345cc8cbb06e8b6f93665fc1 /redis/client.py | |
parent | 615a9abb943c2577217bf88ae4830fb33b07bd98 (diff) | |
download | redis-py-7666f4ffaedb5acf91419110e0b2d66d35f467b4.tar.gz |
fix sentinel state parsing, fixes #462.
Diffstat (limited to 'redis/client.py')
-rw-r--r-- | redis/client.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/redis/client.py b/redis/client.py index 8c7dd72..ccb3606 100644 --- a/redis/client.py +++ b/redis/client.py @@ -114,20 +114,28 @@ def parse_info(response): SENTINEL_STATE_TYPES = { 'can-failover-its-master': int, + 'config-epoch': int, + 'down-after-milliseconds': int, + 'failover-timeout': int, 'info-refresh': int, 'last-hello-message': int, 'last-ok-ping-reply': int, 'last-ping-reply': int, + 'last-ping-sent': int, 'master-link-down-time': int, 'master-port': int, 'num-other-sentinels': int, 'num-slaves': int, 'o-down-time': int, 'pending-commands': int, + 'parallel-syncs': int, 'port': int, 'quorum': int, + 'role-reported-time': int, 's-down-time': int, 'slave-priority': int, + 'slave-repl-offset': int, + 'voted-leader-epoch': int } @@ -146,13 +154,13 @@ def parse_sentinel_state(item): def parse_sentinel(response, **options): "Parse the result of Redis's SENTINEL command" parse = options.get('parse') - response = nativestr(response) if parse == 'SENTINEL_INFO': - return [parse_sentinel_state(item) for item in response] + return [parse_sentinel_state(imap(nativestr, item)) + for item in response] elif parse == 'SENTINEL_INFO_MASTERS': result = {} for item in response: - state = parse_sentinel_state(item) + state = parse_sentinel_state(imap(nativestr, item)) result[state['name']] = state return result elif parse == 'SENTINEL_ADDR_PORT': @@ -173,7 +181,12 @@ def pairs_to_dict_typed(response, type_info): result = {} for key, value in izip(it, it): if key in type_info: - value = type_info[key](value) + try: + value = type_info[key](value) + except: + # if for some reason the value can't be coerced, just use + # the string value + pass result[key] = value return result |