Cache existing SQS queues on startup

This commit is contained in:
Zach Smith 2011-07-14 09:55:38 -07:00
parent 8537a359f6
commit 4d3b490e1e
1 changed files with 11 additions and 1 deletions

View File

@ -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)