rag_saas / app /tasks /runner.py
GodRad's picture
Upload 31 files
abd4592 verified
Raw History Blame Contribute Delete
619 Bytes
import asyncio
from typing import Callable, Any, Dict
from app.core.config import settings
class JobRunner:
def __init__(self):
self.is_hf_mode = settings.HF_SINGLE_PROCESS_MODE
async def run_task(self, func: Callable, *args, **kwargs):
if self.is_hf_mode:
# In-process async task
return asyncio.create_task(func(*args, **kwargs))
else:
# Celery mode (stub)
# In real production, this would call .delay()
print(f"Queueing task to Celery: {func.__name__}")
return None
job_runner = JobRunner()