From d22d055e21e942564bc9ffbd754fdacf61f9aa88 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Fri, 7 Oct 2016 12:54:04 +0100 Subject: [PATCH] only process jobs if they're pending help prevent issues where scheduled jobs are processed twice. note this is NOT a watertight solution - it holds no locks, and there is no guarantee that the status won't have updated between asserting that its status is 'pending' and updating it to be 'in progress' --- app/celery/tasks.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/celery/tasks.py b/app/celery/tasks.py index e784a876f..eca526ee8 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -36,6 +36,9 @@ def process_job(job_id): start = datetime.utcnow() job = dao_get_job_by_id(job_id) + if job.job_status != 'pending': + return + service = job.service total_sent = fetch_todays_total_message_count(service.id)