From 8cb6a043f4767b550f285c22c336c058e449398a Mon Sep 17 00:00:00 2001 From: SilviaAmAm Date: Fri, 10 Jan 2025 14:12:32 +0100 Subject: [PATCH] :wrench: Add timeouts to celery tasks Done in the context of issue https://github.com/maykinmedia/charts/issues/148 --- src/openklant/conf/base.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/openklant/conf/base.py b/src/openklant/conf/base.py index 9865cd0f..52aaf8da 100644 --- a/src/openklant/conf/base.py +++ b/src/openklant/conf/base.py @@ -1,4 +1,5 @@ from open_api_framework.conf.base import * # noqa +from open_api_framework.conf.utils import config # noqa from .api import * # noqa @@ -50,3 +51,13 @@ "openklant.setup_configuration.steps.TokenAuthConfigurationStep", "mozilla_django_oidc_db.setup_configuration.steps.AdminOIDCConfigurationStep", ) + +# +# Celery +# + +# Add (by default) 5 (soft), 15 (hard) minute timeouts to all Celery tasks. +CELERY_TASK_TIME_LIMIT = config("CELERY_TASK_HARD_TIME_LIMIT", default=15 * 60) # hard +CELERY_TASK_SOFT_TIME_LIMIT = config( + "CELERY_TASK_SOFT_TIME_LIMIT", default=5 * 60 +) # soft