diff --git a/rq/queue.py b/rq/queue.py index 2404eea..e9ac069 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -18,6 +18,7 @@ def compact(lst): @total_ordering class Queue(object): redis_queue_namespace_prefix = 'rq:queue:' + redis_queues_keys = 'rq:queues' @classmethod def all(cls, connection=None): @@ -29,7 +30,7 @@ class Queue(object): def to_queue(queue_key): return cls.from_queue_key(as_text(queue_key), connection=connection) - return list(map(to_queue, connection.keys('%s*' % prefix))) + return list(map(to_queue, connection.smembers(cls.redis_queues_keys))) @classmethod def from_queue_key(cls, queue_key, connection=None): @@ -51,6 +52,7 @@ class Queue(object): self._key = '%s%s' % (prefix, name) self._default_timeout = default_timeout self._async = async + self.connection.sadd(self.redis_queues_keys, self.key) @property def key(self): diff --git a/tests/test_queue.py b/tests/test_queue.py index a6dabb2..83e316b 100644 --- a/tests/test_queue.py +++ b/tests/test_queue.py @@ -251,6 +251,17 @@ class TestQueue(RQTestCase): job = q.enqueue(say_hello) self.assertEqual(job.status, Status.QUEUED) + def test_all_queues(self): + """All queues""" + q = Queue('first-queue') + r = Queue('second-queue') + s = Queue('third-queue') + all = Queue.all() + self.assertEquals(len(all), 3) + names = [q.name for q in all] + self.assertTrue('first-queue' in names) + self.assertTrue('second-queue' in names) + self.assertTrue('third-queue' in names) class TestFailedQueue(RQTestCase): def test_requeue_job(self):