# HG changeset patch # User mcroydon # Date 1251236900 0 # Node ID c289deb513832d68c6eb68b25a4300d44ecc0f23 # Parent 4473ee0eff6f8a38c16243c1f0bef9e0deb07ab2 Fixed a bug in the redisd backend that made delete_queue not respect QUEUE_REDIS_DB. diff -r 4473ee0eff6f -r c289deb51383 queues/backends/redisd.py --- a/queues/backends/redisd.py Wed Jul 01 19:01:10 2009 +0000 +++ b/queues/backends/redisd.py Tue Aug 25 21:48:20 2009 +0000 @@ -36,6 +36,12 @@ except ValueError: raise InvalidBackend("Port portion of QUEUE_REDIS_CONNECTION should be an integer.") +def _get_connection(host=host, port=port, db=DB): + kwargs = {'host' : host, 'port' : port} + if DB: + kwargs['db'] = DB + return redis.Redis(**kwargs) + class Queue(BaseQueue): def __init__(self, name): try: @@ -44,7 +50,7 @@ kwargs = {'host' : host, 'port' : int(port)} if DB: kwargs['db'] = DB - self._connection = redis.Redis(**kwargs) + self._connection = _get_connection() except redis.RedisError, e: raise QueueException, "%s" % e @@ -78,9 +84,10 @@ return True def delete_queue(name): + """Delete a queue""" try: - resp = redis.Redis().delete(name) - if resp: + resp = _get_connection().delete(name) + if resp and resp == 1: return True else: return False @@ -88,4 +95,4 @@ raise QueueException, "%s" % e def get_list(): - return redis.Redis().keys('*') + return _get_connection().keys('*')