"""Celery application configuration for Nexus POS background tasks.""" import os from celery import Celery REDIS_URL = os.environ.get('REDIS_URL', 'redis://localhost:6379/0') # Use Redis DB 1 for Celery to avoid clashing with app cache (DB 0) BROKER_URL = os.environ.get('CELERY_BROKER_URL', REDIS_URL.replace('/0', '/1')) BACKEND_URL = os.environ.get('CELERY_RESULT_BACKEND', REDIS_URL.replace('/0', '/1')) celery = Celery( 'nexus', broker=BROKER_URL, backend=BACKEND_URL, include=['tasks'], ) celery.conf.update( task_serializer='json', accept_content=['json'], result_serializer='json', timezone='America/Mexico_City', enable_utc=True, task_track_started=True, task_time_limit=3600, # 1 hour hard limit task_soft_time_limit=3300, # 55 min soft limit worker_prefetch_multiplier=1, result_expires=86400, # Results expire after 24h )