vector-auditor / src /services /async_worker.py
AkshayM
fix models.py: match Neon schema varchar sizes, add email unique constraint
167c070
Raw
History Blame Contribute Delete
400 Bytes
"""Run sync functions in the default executor (non-blocking)."""
import asyncio
from typing import Any, Awaitable, Callable, TypeVar
T = TypeVar("T")
async def run_sync(fn: Callable[..., T], *args: Any, **kwargs: Any) -> T:
"""Run a blocking function in the default thread pool."""
loop = asyncio.get_running_loop()
return await loop.run_in_executor(None, lambda: fn(*args, **kwargs))