# HG changeset patch # User btimby # Date 1371956010 0 # Node ID e1298d634da47b99f442d6fc3cf0b8083ab9216b # Parent 4ad156c4dbeeb8dd237941335f9db96aa205cd86 Some PEP8 changes. Allow the redis client to be provided. This will allow multiple queue instances to share a connection pool. diff -r 4ad156c4dbee -r e1298d634da4 queues/backends/redisd.py --- a/queues/backends/redisd.py Sun May 20 01:49:11 2012 +0000 +++ b/queues/backends/redisd.py Sun Jun 23 02:53:30 2013 +0000 @@ -39,6 +39,7 @@ except ValueError: raise InvalidBackend("Port portion of QUEUE_REDIS_CONNECTION should be an integer.") + def _get_connection(host=host, port=port, db=DB, timeout=TIMEOUT): kwargs = {'host' : host, 'port' : port} if DB: @@ -56,12 +57,13 @@ kwargs['socket_timeout'] = kwargs.pop('timeout') return redis.Redis(**kwargs) + class Queue(BaseQueue): - def __init__(self, name): - try: + def __init__(self, name, connection=None): + try: self.name = name self.backend = 'redis' - self._connection = _get_connection() + self._connection = connection or _get_connection() except redis.RedisError, e: raise QueueException, "%s" % e @@ -101,10 +103,12 @@ def __repr__(self): return "" % self.name + def create_queue(): """This isn't required, so we noop. Kept here for swapability.""" return True + def delete_queue(name): """Delete a queue""" try: @@ -116,5 +120,6 @@ except redis.RedisError, e: raise QueueException, "%s" % e + def get_list(): return _get_connection().keys('*')