Download app/tasks/runner.py from GodRad/rag_saas: direct link, hf CLI and curl.
- Browser
- Download file 619 Bytes
-
https://huggingface.co/spaces/GodRad/rag_saas/resolve/main/app/tasks/runner.py
- Command line
-
hf download hf://spaces/GodRad/rag_saas/app/tasks/runner.py
-
curl -L -o runner.py https://huggingface.co/spaces/GodRad/rag_saas/resolve/main/app/tasks/runner.py
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() | |