23 lines
632 B
Python
23 lines
632 B
Python
from app.core.celery_app import celery_app
|
|
from app.core.logging import log
|
|
|
|
|
|
@celery_app.task(bind=True)
|
|
def add_numbers(self, x: int, y: int) -> int:
|
|
"""Simple task to add two numbers"""
|
|
log.info(f"Adding numbers: {x} + {y}")
|
|
result = x + y
|
|
log.info(f"Result: {result}")
|
|
return result
|
|
|
|
|
|
@celery_app.task(bind=True)
|
|
def long_running_task(self, duration: int = 10):
|
|
"""Simulate a long running task"""
|
|
import time
|
|
|
|
log.info(f"Starting long running task for {duration} seconds")
|
|
time.sleep(duration)
|
|
log.info("Long running task completed")
|
|
return f"Task completed after {duration} seconds"
|