mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 20:59:05 +00:00
- 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
21 lines
466 B
Python
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
|