Skip to content
Snippets Groups Projects
Commit b3fb2b3c authored by Erik Reid's avatar Erik Reid
Browse files

use new socket timeout params for redis/sentinel connections

parent 525a6ed0
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,9 @@ import redis.sentinel
logger = logging.getLogger(__name__)
DEFAULT_REDIS_SENTINEL_TIMEOUT = 0.1
DEFAULT_SENTINEL_SOCKET_TIMEOUT = 0.1
DB_LATCH_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
......@@ -102,19 +105,23 @@ def _get_redis(config, dbid=None):
dbid = min(config['redis-databases'])
kwargs = {
'db': dbid,
'socket_timeout': 0.1
'db': dbid
}
if 'sentinel' in config:
kwargs['socket_timeout'] = config['sentinel'].get(
'sentinel_socket_timeout', DEFAULT_SENTINEL_SOCKET_TIMEOUT)
sentinel = redis.sentinel.Sentinel([(
config['sentinel']['hostname'],
config['sentinel']['port'])],
**kwargs)
return sentinel.master_for(
config['sentinel']['name'],
socket_timeout=0.1)
socket_timeout=config['sentinel'].get(
'redis_socket_timeout', DEFAULT_REDIS_SENTINEL_TIMEOUT))
else:
kwargs['socket_timeout'] = config['redis'].get(
'socket_timeout', DEFAULT_REDIS_SENTINEL_TIMEOUT)
return redis.StrictRedis(
host=config['redis']['hostname'],
port=config['redis']['port'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment