From 30c31e52ea3b551ed06ae5a4289a73e92e48e825 Mon Sep 17 00:00:00 2001 From: Omer Lachish Date: Mon, 25 Nov 2019 10:37:22 +0200 Subject: [PATCH] don't try to purge jobs which have already been deleted --- redash/tasks/general.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redash/tasks/general.py b/redash/tasks/general.py index bfe2a1065d..f4927ba11b 100644 --- a/redash/tasks/general.py +++ b/redash/tasks/general.py @@ -71,7 +71,7 @@ def purge_failed_jobs(): for queue in Queue.all(): failed_job_ids = FailedJobRegistry(queue=queue).get_job_ids() failed_jobs = Job.fetch_many(failed_job_ids, rq_redis_connection) - stale_jobs = [job for job in failed_jobs if (datetime.utcnow() - job.ended_at).seconds > settings.JOB_DEFAULT_FAILURE_TTL] + stale_jobs = [job for job in failed_jobs if job and (datetime.utcnow() - job.ended_at).seconds > settings.JOB_DEFAULT_FAILURE_TTL] for job in stale_jobs: job.delete()