Files
triviathang/backend/celery_app.py
2025-12-22 14:47:25 -05:00

30 lines
723 B
Python

from celery import Celery
from backend.config import config
import os
def make_celery():
"""Create Celery instance"""
config_name = os.environ.get('FLASK_ENV', 'development')
app_config = config.get(config_name, config['default'])
celery = Celery(
'trivia_tasks',
broker=app_config.CELERY_BROKER_URL,
backend=app_config.CELERY_RESULT_BACKEND
)
celery.conf.update(
task_track_started=True,
task_time_limit=app_config.CELERY_TASK_TIME_LIMIT,
result_expires=3600, # Results expire after 1 hour
)
return celery
celery = make_celery()
# Import tasks to register them with Celery
from backend.tasks import youtube_tasks # noqa: E402, F401