From 06e5f2b69cb751c1011d2e182d3e9f9a117ce822 Mon Sep 17 00:00:00 2001 From: Devin Gaffney Date: Wed, 13 Nov 2024 14:19:30 -0800 Subject: [PATCH] refactor to get rid of persistent queues and change to singular lookup --- lib/queue/queue.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/queue/queue.py b/lib/queue/queue.py index 464bc1e..67f8a23 100644 --- a/lib/queue/queue.py +++ b/lib/queue/queue.py @@ -19,7 +19,6 @@ def __init__(self): Start a specific queue - must pass input_queue_name. """ self.sqs_lock = Lock() - self.sqs = self.get_sqs() @staticmethod def get_queue_prefix(): @@ -82,7 +81,7 @@ def create_queue(self, queue_name: str) -> boto3.resources.base.ServiceResource: # Optionally enable content-based deduplication for FIFO queues attributes['ContentBasedDeduplication'] = 'true' # Include other FIFO-specific attributes as needed - return self.sqs.create_queue( + return self.get_sqs().create_queue( QueueName=queue_name, Attributes=attributes ) @@ -92,14 +91,7 @@ def get_or_create_queues(self, queue_name: str) -> List[boto3.resources.base.Ser Initialize all queues for the given worker - try to create them if they are not found by name for whatever reason """ try: - found_queues = [q for q in self.sqs.queues.filter(QueueNamePrefix=queue_name)] - exact_match_queues = [queue for queue in found_queues if queue.attributes['QueueArn'].split(':')[-1] == queue_name] - logger.info(f"found queues are {found_queues}") - logger.info(f"exact queues are {exact_match_queues}") - if exact_match_queues: - return exact_match_queues - else: - return [self.create_queue(queue_name)] + return [self.get_sqs().get_queue_by_name(QueueName=queue_name)] except botocore.exceptions.ClientError as e: if e.response['Error']['Code'] == "AWS.SimpleQueueService.NonExistentQueue": return [self.create_queue(queue_name)]