37 lines
864 B
Python
37 lines
864 B
Python
"""
|
|
Celery worker for MyDocManager document processing tasks.
|
|
|
|
This module contains all Celery tasks for processing documents.
|
|
"""
|
|
import os
|
|
|
|
from celery import Celery
|
|
|
|
# Environment variables
|
|
REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379/0")
|
|
MONGODB_URL = os.getenv("MONGODB_URL", "mongodb://localhost:27017")
|
|
|
|
# Initialize Celery app
|
|
celery_app = Celery(
|
|
"mydocmanager_worker",
|
|
broker=REDIS_URL,
|
|
backend=REDIS_URL,
|
|
)
|
|
|
|
celery_app.autodiscover_tasks(["tasks.document_processing"])
|
|
|
|
# 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=300, # 5 minutes
|
|
task_soft_time_limit=240, # 4 minutes
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
celery_app.start()
|