Files
reflector/server/reflector/asynctask.py
Mathieu Virbel 06639d4d8f feat: migrate SQLAlchemy from 1.4 to 2.0 with ORM style
- Remove encode/databases dependency, use native SQLAlchemy 2.0 async
- Convert all table definitions to Declarative Mapping pattern
- Update all controllers to accept session parameter (dependency injection)
- Convert all queries from Core style to ORM style
- Remove PostgreSQL compatibility checks (PostgreSQL only now)
- Add proper typing for engine and session factories
2025-09-18 12:19:53 -06:00

21 lines
466 B
Python

import asyncio
import functools
def asynctask(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
async def run_async():
return await f(*args, **kwargs)
coro = run_async()
try:
loop = asyncio.get_running_loop()
except RuntimeError:
loop = None
if loop and loop.is_running():
return loop.run_until_complete(coro)
return asyncio.run(coro)
return wrapper