schon/evibes/celery.py
Egor fureunoir Gorbunov f37206ed4e Features: 1) Add Redis sysctl configurations to docker-compose.yml; 2) Introduce broker heartbeat and transport options for Celery in settings/celery.py.
Fixes: 1) Extract and centralize broker transport options in `settings/celery.py`; 2) Remove redundant Celery settings from `celery.py`.

Extra: 1) Cleanup and streamline Celery configuration in `celery.py`.
2025-07-03 17:14:22 +03:00

30 lines
844 B
Python

import os
from celery import Celery
from evibes.settings import REDIS_PASSWORD, TIME_ZONE
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "evibes.settings")
app = Celery("evibes")
app.conf.update(
worker_hijack_root_logger=False,
worker_log_format="[%(asctime)s: %(levelname)s/%(processName)s] %(name)s: %(message)s",
worker_task_log_format="[%(asctime)s: %(levelname)s/%(processName)s] %(name)s: %(message)s",
broker_connection_retry_on_startup=True,
task_serializer="json",
result_serializer="json",
result_compression="zlib",
accept_content=["json"],
task_acks_late=True,
task_reject_on_worker_lost=True,
)
app.conf.task_routes = {
"core.tasks.update_products_task": {"queue": "stock_updater"},
}
app.config_from_object("django.conf:settings", namespace="CELERY")
app.autodiscover_tasks()