From 6b8db9f2e6986279edd586695602b1a51449e861 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 1 May 2024 04:58:44 +0000 Subject: [PATCH] sqs settings modified --- .../management/commands/custom_runserver.py | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/kitchen_counter/conversion/management/commands/custom_runserver.py b/kitchen_counter/conversion/management/commands/custom_runserver.py index 6b97a40..f5cae9d 100755 --- a/kitchen_counter/conversion/management/commands/custom_runserver.py +++ b/kitchen_counter/conversion/management/commands/custom_runserver.py @@ -175,26 +175,31 @@ class Command(BaseCommand): print("Started Executin this from conversion") queue = sqs.get_queue_by_name(QueueName="mnfqueue") # try: - messages = queue.receive_messages( - MessageAttributeNames=["All"], - MaxNumberOfMessages=5, - WaitTimeSeconds=20, - ) - for msg in messages: - try: - print("Received message: %s: %s", msg.message_id, msg.body) - print(type(msg.body)) - body_dict = json.loads(msg.body) - if body_dict['service_type'] == "conversion": + while True: - run_conversion(msg) - - elif body_dict['service_type'] == "audit": + messages = queue.receive_messages( + MessageAttributeNames=["All"], + MaxNumberOfMessages=5, + WaitTimeSeconds=10, + ) + if len(messages) > 0: - run_audit(msg) + for msg in messages: + try: + print("Received message: %s: %s", msg.message_id, msg.body) + print(type(msg.body)) + body_dict = json.loads(msg.body) + if body_dict['service_type'] == "conversion": - except Exception as error: - print("error execution from queue: %s", error) - + run_conversion(msg) + + elif body_dict['service_type'] == "audit": + + run_audit(msg) + + except Exception as error: + print("error execution from queue: %s", error) + else: + break print("Completed All Execution")