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()