From 30cd6573ef75af66f942f458a425f0b4a6e3ffc6 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Thu, 10 Jul 2025 14:55:59 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7(backend)=20refine=20Celery=20retry?= =?UTF-8?q?=20policy=20to=20HTTP=20errors=20only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only retry jobs on HTTP errors (docs push failures) rather than all errors. Skip retries for Whisper processing failures as they won't succeed on retry. --- src/summary/summary/core/celery_worker.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/summary/summary/core/celery_worker.py b/src/summary/summary/core/celery_worker.py index 2cb139aa..a34a8350 100644 --- a/src/summary/summary/core/celery_worker.py +++ b/src/summary/summary/core/celery_worker.py @@ -12,7 +12,7 @@ from celery import Celery, signals from celery.utils.log import get_task_logger from minio import Minio from mutagen import File -from requests import Session +from requests import Session, exceptions from requests.adapters import HTTPAdapter from urllib3.util import Retry @@ -221,7 +221,11 @@ def process_audio_transcribe_summarize(filename: str, email: str, sub: str): logger.debug("Response body: %s", response.text) -@celery.task(bind=True, max_retries=settings.celery_max_retries) +@celery.task( + bind=True, + autoretry_for=[exceptions.HTTPError], + max_retries=settings.celery_max_retries, +) def process_audio_transcribe_summarize_v2( self, filename: str, email: str, sub: str, received_at: float ):