Skip to content

Commit

Permalink
CH: support redis-py < 2.10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
fvennetier committed Sep 11, 2019
1 parent 734402a commit 4abe769
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion oioswift/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.10.0'
__version__ = '1.10.1'
15 changes: 14 additions & 1 deletion oioswift/common/middleware/container_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ class RedisDb(object):
return lst
"""

# Imported from redis-py, for compatibility with pre 2.10.6 versions.
URL_QUERY_ARGUMENT_PARSERS = {
'socket_timeout': float,
'socket_connect_timeout': float,
'socket_keepalive': config_true_value,
'retry_on_timeout': config_true_value,
'max_connections': int,
'health_check_interval': int,
}

def __init__(self, redis_host=None,
sentinel_hosts=None, sentinel_name=None,
**connection_kwargs):
Expand Down Expand Up @@ -189,7 +199,10 @@ def _filter_conn_kwargs(self, connection_kwargs):
Keep only keyword arguments known by Redis classes, cast them to
the appropriate type.
"""
parsers = self.__redis_mod.connection.URL_QUERY_ARGUMENT_PARSERS
if hasattr(self.__redis_mod.connection, 'URL_QUERY_ARGUMENT_PARSERS'):
parsers = self.__redis_mod.connection.URL_QUERY_ARGUMENT_PARSERS
else:
parsers = RedisDb.URL_QUERY_ARGUMENT_PARSERS
return {k: parsers[k](v)
for k, v in connection_kwargs.items()
if k in parsers}
Expand Down

0 comments on commit 4abe769

Please sign in to comment.