Files
Ai/tasks/celery_tasks.py
T
sajad-dev 09e0c26c68 Add Redis service and Celery configuration to Docker setup
- Introduced Redis service in both docker-compose files for production and development.
- Updated web and celery services to use Redis as the broker and result backend.
- Added necessary environment variables for Celery in settings.py.
- Included new tasks and soil_data apps in Django settings and updated URL routing.
- Updated requirements.txt to include Celery and Redis dependencies.
2026-02-27 13:09:00 +03:30

16 lines
499 B
Python

import time
from config.celery import app
@app.task(bind=True)
def sample_task(self, duration: int = 1):
"""تسک نمونه برای تست. duration تعداد ثانیه‌ای که تسک طول می‌کشه."""
for i in range(duration):
self.update_state(
state="PROGRESS",
meta={"current": i + 1, "total": duration, "message": "در حال پردازش..."},
)
time.sleep(1)
return {"status": "completed", "duration": duration}