From be50b0e05604bccd91a511c721c5b3f87e258a56 Mon Sep 17 00:00:00 2001 From: Parsa Nazer Date: Thu, 28 May 2026 10:32:13 +0330 Subject: [PATCH] update celery settings --- backend/core/settings/production.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/core/settings/production.py b/backend/core/settings/production.py index a2671fc..1a3f6b6 100644 --- a/backend/core/settings/production.py +++ b/backend/core/settings/production.py @@ -58,6 +58,18 @@ CELERY_RESULT_BACKEND = "redis://redis:6379/0" CELERY_TIMEZONE = "UTC" CELERY_BEAT_SCHEDULER = 'django_celery_beat.schedulers:DatabaseScheduler' +# Kill any task that runs longer than 5 minutes — prevents a hung external +# call (Nobitex, bank verify, SMS) from freezing the worker pool indefinitely. +CELERY_TASK_TIME_LIMIT = 300 +CELERY_TASK_SOFT_TIME_LIMIT = 240 + +# Recycle each worker child after 200 tasks to release memory/connections. +CELERY_WORKER_MAX_TASKS_PER_CHILD = 200 + +# Expire task results after 1 hour instead of the 1-day default. We don't +# read results, so this just keeps Redis lean. +CELERY_RESULT_EXPIRES = 3600 + from celery.schedules import crontab CELERY_BEAT_SCHEDULE = {