diff --git a/.env b/.env index 8f1ec0ba7e8..f074f658b39 100644 --- a/.env +++ b/.env @@ -90,3 +90,4 @@ jQIDAQAB -----END PUBLIC KEY-----" # openssl rand -base64 32 DJANGO_SECRETS_ENCRYPTION_KEY="oE/ltOhp/n1TdbHjVmzcjDPLcLA41CVI/4Rk+UB5ESc=" +DJANGO_BROKER_VISIBILITY_TIMEOUT=86400 diff --git a/api/.env.example b/api/.env.example index f0e72562fea..4b0894b3ba9 100644 --- a/api/.env.example +++ b/api/.env.example @@ -22,6 +22,7 @@ DJANGO_SECRETS_ENCRYPTION_KEY="" # Decide whether to allow Django manage database table partitions DJANGO_MANAGE_DB_PARTITIONS=[True|False] DJANGO_CELERY_DEADLOCK_ATTEMPTS=5 +DJANGO_BROKER_VISIBILITY_TIMEOUT=86400 # PostgreSQL settings # If running django and celery on host, use 'localhost', else use 'postgres-db' diff --git a/api/src/backend/config/celery.py b/api/src/backend/config/celery.py index e5b0c304921..4486a0bf97e 100644 --- a/api/src/backend/config/celery.py +++ b/api/src/backend/config/celery.py @@ -1,10 +1,21 @@ from celery import Celery, Task +from config.env import env + +BROKER_VISIBILITY_TIMEOUT = env.int("DJANGO_BROKER_VISIBILITY_TIMEOUT", default=86400) celery_app = Celery("tasks") celery_app.config_from_object("django.conf:settings", namespace="CELERY") celery_app.conf.update(result_extended=True, result_expires=None) +celery_app.conf.broker_transport_options = { + "visibility_timeout": BROKER_VISIBILITY_TIMEOUT +} +celery_app.conf.result_backend_transport_options = { + "visibility_timeout": BROKER_VISIBILITY_TIMEOUT +} +celery_app.conf.visibility_timeout = BROKER_VISIBILITY_TIMEOUT + celery_app.autodiscover_tasks(["api"])