From 0d46fd7663b45720f99e255bf354a9ece72042fe Mon Sep 17 00:00:00 2001 From: Marcin Kaluza Date: Mon, 8 Oct 2018 10:22:04 +0200 Subject: [PATCH] Publisher: allow overriding default connection This can for example be used for pipelining --- ws4redis/publisher.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ws4redis/publisher.py b/ws4redis/publisher.py index 7f70bc7b..ead0f847 100644 --- a/ws4redis/publisher.py +++ b/ws4redis/publisher.py @@ -15,11 +15,12 @@ redis_connection_pool = ConnectionPool(**settings.WS4REDIS_CONNECTION) class RedisPublisher(RedisStore): - def __init__(self, **kwargs): + def __init__(self, connection = None, **kwargs): """ Initialize the channels for publishing messages through the message queue. """ - connection = StrictRedis(connection_pool=redis_connection_pool) + if connection == None: + connection = StrictRedis(connection_pool=redis_connection_pool) super(RedisPublisher, self).__init__(connection) for key in self._get_message_channels(**kwargs): self._publishers.add(key)