"""Celery application configuration.""" import os from celery import Celery # Get configuration from environment variables CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL", "redis://localhost:6379/0") CELERY_RESULT_BACKEND = os.getenv("CELERY_RESULT_BACKEND", "redis://localhost:6379/0") # Configure Celery celery_app = Celery( "yottob", broker=CELERY_BROKER_URL, backend=CELERY_RESULT_BACKEND, include=["download_service"] ) # Celery configuration celery_app.conf.update( task_serializer="json", accept_content=["json"], result_serializer="json", timezone="UTC", enable_utc=True, task_track_started=True, task_time_limit=3600, # 1 hour max per task task_soft_time_limit=3300, # 55 minutes soft limit worker_prefetch_multiplier=1, # Process one task at a time worker_max_tasks_per_child=50, # Restart worker after 50 tasks )