changeset 16:c289deb51383

Fixed a bug in the redisd backend that made delete_queue not respect QUEUE_REDIS_DB.
author mcroydon
date Tue, 25 Aug 2009 21:48:20 +0000
parents 4473ee0eff6f
children a0d3e275c885
files queues/backends/redisd.py
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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('*')