Se agrego celery y respuestas instantaneas
This commit is contained in:
27
celery_app.py
Normal file
27
celery_app.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from celery import Celery
|
||||
from core.config import settings
|
||||
import os
|
||||
|
||||
# Configuración de Celery
|
||||
celery_app = Celery(
|
||||
"microservice",
|
||||
broker=f"redis://{os.getenv('REDIS_HOST', 'localhost')}:{os.getenv('REDIS_PORT', '6379')}/{os.getenv('REDIS_DB', '0')}",
|
||||
backend=f"redis://{os.getenv('REDIS_HOST', 'localhost')}:{os.getenv('REDIS_PORT', '6379')}/{os.getenv('REDIS_DB', '0')}",
|
||||
include=['tasks']
|
||||
)
|
||||
|
||||
# Configuración adicional
|
||||
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 timeout
|
||||
worker_prefetch_multiplier=1,
|
||||
worker_max_tasks_per_child=1000,
|
||||
)
|
||||
|
||||
# Autodiscovery of tasks
|
||||
celery_app.autodiscover_tasks()
|
||||
Reference in New Issue
Block a user