From ef859db6b0bbeaf165d31e446ceea08b320666f7 Mon Sep 17 00:00:00 2001 From: Alexey Tsitkin Date: Wed, 21 Feb 2018 15:30:07 -0800 Subject: [PATCH 1/5] temporary commit --- eb_sqs/worker/service.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/eb_sqs/worker/service.py b/eb_sqs/worker/service.py index bd13cd1..39f930d 100644 --- a/eb_sqs/worker/service.py +++ b/eb_sqs/worker/service.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals from datetime import timedelta, datetime +from time import sleep import boto3 import logging @@ -83,12 +84,12 @@ def delete_messages(self, queue, msg_entries): # type: (Queue, list) -> None if len(msg_entries) > 0: response = queue.delete_messages(Entries=msg_entries) - logger.debug('[django-eb-sqs] Deleted {} messages successfully'.format( - len(response.get('Successful', [])) - )) - logger.debug('[django-eb-sqs] Failed deleting {} messages'.format( - len(response.get('Failed', [])) - )) + + # logging + failed = response.get('Failed', []) + num_failed = len(failed) + if num_failed > 0: + logger.warning('[django-eb-sqs] Failed deleting {} messages: {}'.format(num_failed, failed)) def poll_messages(self, queue): # type: (Queue) -> list @@ -100,11 +101,13 @@ def poll_messages(self, queue): def process_message(self, msg, worker): # type: (Message, Worker) -> None logger.debug('[django-eb-sqs] Read message {}'.format(msg.message_id)) - try: - worker.execute(msg.body) - logger.debug('[django-eb-sqs] Processed message {}'.format(msg.message_id)) - except Exception as exc: - logger.error('[django-eb-sqs] Unhandled error: {}'.format(exc), exc_info=1) + sleep(10) + print('Retry number {}'.format(msg.attributes['ApproximateReceiveCount'])) + # try: + # worker.execute(msg.body) + # logger.debug('[django-eb-sqs] Processed message {}'.format(msg.message_id)) + # except Exception as exc: + # logger.error('[django-eb-sqs] Unhandled error: {}'.format(exc), exc_info=1) def get_queues_by_names(self, sqs, queue_names): # type: (ServiceResource, list) -> list From d0345089eb939e59947f7dba86d9758be735aca2 Mon Sep 17 00:00:00 2001 From: Alexey Tsitkin Date: Thu, 22 Feb 2018 09:29:05 -0800 Subject: [PATCH 2/5] temporary commit --- eb_sqs/worker/service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eb_sqs/worker/service.py b/eb_sqs/worker/service.py index 39f930d..ff48b84 100644 --- a/eb_sqs/worker/service.py +++ b/eb_sqs/worker/service.py @@ -102,7 +102,7 @@ def process_message(self, msg, worker): # type: (Message, Worker) -> None logger.debug('[django-eb-sqs] Read message {}'.format(msg.message_id)) sleep(10) - print('Retry number {}'.format(msg.attributes['ApproximateReceiveCount'])) + print('Retry number {}'.format(msg.attributes.get('ApproximateReceiveCount', 0))) # try: # worker.execute(msg.body) # logger.debug('[django-eb-sqs] Processed message {}'.format(msg.message_id)) From a20d4005db4be7f1d6cc952a3402b3de2660d5a7 Mon Sep 17 00:00:00 2001 From: Alexey Tsitkin Date: Thu, 22 Feb 2018 09:32:00 -0800 Subject: [PATCH 3/5] temporary commit --- eb_sqs/worker/service.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eb_sqs/worker/service.py b/eb_sqs/worker/service.py index ff48b84..0e38ee3 100644 --- a/eb_sqs/worker/service.py +++ b/eb_sqs/worker/service.py @@ -101,8 +101,10 @@ def poll_messages(self, queue): def process_message(self, msg, worker): # type: (Message, Worker) -> None logger.debug('[django-eb-sqs] Read message {}'.format(msg.message_id)) + if msg.attributes: + print('Retry number {}'.format(msg.attributes.get('ApproximateReceiveCount', 0))) sleep(10) - print('Retry number {}'.format(msg.attributes.get('ApproximateReceiveCount', 0))) + # try: # worker.execute(msg.body) # logger.debug('[django-eb-sqs] Processed message {}'.format(msg.message_id)) From cf84b94f058df5144d116c12fc511c358d749691 Mon Sep 17 00:00:00 2001 From: Alexey Tsitkin Date: Thu, 22 Feb 2018 09:35:43 -0800 Subject: [PATCH 4/5] temporary commit --- eb_sqs/worker/service.py | 1 + 1 file changed, 1 insertion(+) diff --git a/eb_sqs/worker/service.py b/eb_sqs/worker/service.py index 0e38ee3..11693c3 100644 --- a/eb_sqs/worker/service.py +++ b/eb_sqs/worker/service.py @@ -101,6 +101,7 @@ def poll_messages(self, queue): def process_message(self, msg, worker): # type: (Message, Worker) -> None logger.debug('[django-eb-sqs] Read message {}'.format(msg.message_id)) + print(msg) if msg.attributes: print('Retry number {}'.format(msg.attributes.get('ApproximateReceiveCount', 0))) sleep(10) From 4ad7dc3a76092e1b47d031212d96ad05c7ab1b29 Mon Sep 17 00:00:00 2001 From: Alexey Tsitkin Date: Thu, 22 Feb 2018 09:58:10 -0800 Subject: [PATCH 5/5] cleanup --- eb_sqs/worker/service.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/eb_sqs/worker/service.py b/eb_sqs/worker/service.py index 11693c3..87a45c9 100644 --- a/eb_sqs/worker/service.py +++ b/eb_sqs/worker/service.py @@ -1,7 +1,6 @@ from __future__ import absolute_import, unicode_literals from datetime import timedelta, datetime -from time import sleep import boto3 import logging @@ -101,16 +100,11 @@ def poll_messages(self, queue): def process_message(self, msg, worker): # type: (Message, Worker) -> None logger.debug('[django-eb-sqs] Read message {}'.format(msg.message_id)) - print(msg) - if msg.attributes: - print('Retry number {}'.format(msg.attributes.get('ApproximateReceiveCount', 0))) - sleep(10) - - # try: - # worker.execute(msg.body) - # logger.debug('[django-eb-sqs] Processed message {}'.format(msg.message_id)) - # except Exception as exc: - # logger.error('[django-eb-sqs] Unhandled error: {}'.format(exc), exc_info=1) + try: + worker.execute(msg.body) + logger.debug('[django-eb-sqs] Processed message {}'.format(msg.message_id)) + except Exception as exc: + logger.error('[django-eb-sqs] Unhandled error: {}'.format(exc), exc_info=1) def get_queues_by_names(self, sqs, queue_names): # type: (ServiceResource, list) -> list