From 4d3b490e1eea8b1ac84b698f31494b17771b73d1 Mon Sep 17 00:00:00 2001 From: Zach Smith Date: Thu, 14 Jul 2011 09:55:38 -0700 Subject: [PATCH] Cache existing SQS queues on startup --- kombu/transport/SQS.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kombu/transport/SQS.py b/kombu/transport/SQS.py index 588315ad..b115bc88 100644 --- a/kombu/transport/SQS.py +++ b/kombu/transport/SQS.py @@ -1,4 +1,3 @@ - """ kombu.transport.SQS =================== @@ -129,6 +128,17 @@ class Channel(virtual.Channel): _queue_cache = {} _noack_queues = set() + def __init__(self, *args, **kwargs): + super(Channel, self).__init__(*args, **kwargs) + + # SQS blows up when you try to create a new queue if one alread exists with a different + # visability_timeout, so this populates the queue_cache to protect from recreating + # queues that already exist + + queues = self.sqs.get_all_queues() + for queue in queues: + self._queue_cache[queue.name] = queue + def basic_consume(self, queue, no_ack, *args, **kwargs): if no_ack: self._noack_queues.add(queue)