Skip to content

Commit 838d348

Browse files
committed
Fix the healthcheck
Currently we update the health check file on end of process messages instead now we update the health check file after processing each queue
1 parent e9e3295 commit 838d348

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

eb_sqs/worker/service.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ def process_queues(self, queue_names):
4444
static_queues = queues
4545
last_update_time = timezone.now() - timedelta(seconds=settings.REFRESH_PREFIX_QUEUES_S)
4646

47-
self.write_healthcheck_file()
48-
last_healthcheck_time = timezone.now()
49-
5047
logger.debug('[django-eb-sqs] Connected to SQS: {}'.format(', '.join(queue_names)))
5148

5249
worker = WorkerFactory.default().create()
@@ -75,11 +72,11 @@ def process_queues(self, queue_names):
7572
else:
7673
self.process_messages(queues, worker, static_queues)
7774

78-
if timezone.now() - timedelta(seconds=settings.MIN_HEALTHCHECK_WRITE_PERIOD_S) > last_healthcheck_time:
79-
self.write_healthcheck_file()
80-
last_healthcheck_time = timezone.now()
81-
8275
def process_messages(self, queues, worker, static_queues):
76+
77+
self.write_healthcheck_file()
78+
last_healthcheck_time = timezone.now()
79+
8380
# type: (list, Worker, list) -> None
8481
for queue in queues:
8582
try:
@@ -101,6 +98,10 @@ def process_messages(self, queues, worker, static_queues):
10198
self.delete_messages(queue, msg_entries)
10299

103100
self._send_signal(MESSAGES_DELETED, messages=messages)
101+
102+
if timezone.now() - timedelta(seconds=settings.MIN_HEALTHCHECK_WRITE_PERIOD_S) > last_healthcheck_time:
103+
self.write_healthcheck_file()
104+
last_healthcheck_time = timezone.now()
104105
except ClientError as exc:
105106
error_code = exc.response.get('Error', {}).get('Code', None)
106107
if error_code == 'AWS.SimpleQueueService.NonExistentQueue' and queue not in static_queues:

0 commit comments

Comments
 (0)