From 95a2bed3337fb2d7a32c259e4ed57916dcdb3c63 Mon Sep 17 00:00:00 2001 From: Matvey Kukuy Date: Tue, 20 Aug 2024 11:35:54 +0300 Subject: [PATCH] fix: Retry task only if it's an Arq task (#1640) --- keep/api/tasks/process_event_task.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/keep/api/tasks/process_event_task.py b/keep/api/tasks/process_event_task.py index dc613c2fe..6f6d664aa 100644 --- a/keep/api/tasks/process_event_task.py +++ b/keep/api/tasks/process_event_task.py @@ -472,7 +472,9 @@ def process_event( ) except Exception: logger.exception("Error processing event", extra=extra_dict) - raise Retry(defer=ctx["job_try"] * TIMES_TO_RETRY_JOB) + # Retrying only if context is present (running the job in arq worker) + if bool(ctx): + raise Retry(defer=ctx["job_try"] * TIMES_TO_RETRY_JOB) finally: session.close() logger.info("Event processed", extra=extra_dict)