dedc3b4183
- Full FastAPI backend with JWT auth, file management, processing pipeline, memory CRUD, barcode mappings, config management, cloud sync - Vue 3 + Element Plus frontend with dashboard, task history, HTTP logs, memory editor, barcode editor, config editor, sync page - HTTP request logging middleware with SQLite persistence - Task history tracking with progress and retry support - File metadata recording for upload/download operations - WebAuth section in config.ini for bcrypt password storage - Bug fix: logs.py count query returns tuple not dict Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
20 lines
585 B
Python
20 lines
585 B
Python
"""Async wrapper for synchronous app/ services"""
|
|
|
|
import asyncio
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
from typing import Callable, Any
|
|
|
|
|
|
class ServiceWrapper:
|
|
"""Wraps synchronous services for async FastAPI endpoints."""
|
|
|
|
def __init__(self, max_workers: int = 3):
|
|
self._executor = ThreadPoolExecutor(max_workers=max_workers)
|
|
|
|
async def run_sync(self, fn: Callable, *args, **kwargs) -> Any:
|
|
loop = asyncio.get_event_loop()
|
|
return await loop.run_in_executor(
|
|
self._executor,
|
|
lambda: fn(*args, **kwargs)
|
|
)
|