From d5eb0d7da726b3cd89f4d6ca82c12276ebfa4200 Mon Sep 17 00:00:00 2001 From: Ask Solem Date: Mon, 21 Mar 2016 13:24:43 -0700 Subject: [PATCH] Redis: Adds socket_keepalive,socket_keepalive_options,socket_connect_timeout options. Closes celery/celery/#3124 --- kombu/transport/redis.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/kombu/transport/redis.py b/kombu/transport/redis.py index b4950e6f..a5222f6a 100644 --- a/kombu/transport/redis.py +++ b/kombu/transport/redis.py @@ -396,6 +396,9 @@ class Channel(virtual.Channel): visibility_timeout = 3600 # 1 hour priority_steps = PRIORITY_STEPS socket_timeout = None + socket_connect_timeout = None + socket_keepalive = None + socket_keepalive_options = None max_connections = 10 #: Transport option to disable fanout keyprefix. #: Can also be string, in which case it changes the default @@ -454,6 +457,9 @@ class Channel(virtual.Channel): 'fanout_prefix', 'fanout_patterns', 'socket_timeout', + 'socket_connect_timeout', + 'socket_keepalive', + 'socket_keepalive_options', 'queue_order_strategy', 'max_connections', 'priority_steps') # <-- do not add comma here! @@ -844,12 +850,17 @@ class Channel(virtual.Channel): def _connparams(self, async=False): conninfo = self.connection.client - connparams = {'host': conninfo.hostname or '127.0.0.1', - 'port': conninfo.port or self.connection.default_port, - 'virtual_host': conninfo.virtual_host, - 'password': conninfo.password, - 'max_connections': self.max_connections, - 'socket_timeout': self.socket_timeout} + connparams = { + 'host': conninfo.hostname or '127.0.0.1', + 'port': conninfo.port or self.connection.default_port, + 'virtual_host': conninfo.virtual_host, + 'password': conninfo.password, + 'max_connections': self.max_connections, + 'socket_timeout': self.socket_timeout, + 'socket_connect_timeout': self.socket_connect_timeout, + 'socket_keepalive': self.socket_keepalive, + 'socket_keepalive_options': self.socket_keepalive_options, + } if conninfo.ssl: # Connection(ssl={}) can be a dict like in amqplib. connparams['ssl'] = True