from celery import Celery from backend.config import Config def make_celery(app_name=__name__): """Create and configure Celery instance.""" celery = Celery(app_name) # Configure Celery using the Flask app's config celery.conf.update( broker_url=Config.CELERY_BROKER_URL, result_backend=Config.CELERY_RESULT_BACKEND, task_serializer='json', accept_content=['json'], result_serializer='json', timezone='UTC', enable_utc=True, result_expires=3600, # Results expire after 1 hour task_routes={ # Example routing - adjust based on your actual tasks # 'backend.tasks.example_task': {'queue': 'default'}, }, broker_connection_retry_on_startup=True, ) return celery # Create the main Celery instance celery = make_celery()