You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Python core SDK is fully async/ASGI (Starlette + Uvicorn), e.g. UseCase.execute is declared async def:
code/py/modular_api/src/modular_api/core/usecase.py:200 -> async def execute(self) -> O
But the Python db contracts are synchronous (def, not async def):
code/py/modular_api_sqlserver/src/modular_api_sqlserver/db_client.py:212-249 -> DbSessionProvider.acquire/close, DbCommandExecutor.query/execute/scalar, DbTransactionRunner.run are all sync. Same in modular_api_postgres.
Why this is a defect, not an idiomatic choice
An async def execute() use case that calls a synchronous db repository performs blocking network I/O inside the asyncio event loop, degrading the concurrency of the whole ASGI server. TS and Dart contracts are already async (Promise/Future), so this is also a real parity gap specific to Python.
Breaking in Python (signatures change). There are no Python consumers in production today (current consumers are TypeScript), so the cost of doing this now is ~0 and grows over time.
Problem
The Python core SDK is fully async/ASGI (Starlette + Uvicorn), e.g.
UseCase.executeis declaredasync def:code/py/modular_api/src/modular_api/core/usecase.py:200->async def execute(self) -> OBut the Python db contracts are synchronous (
def, notasync def):code/py/modular_api_sqlserver/src/modular_api_sqlserver/db_client.py:212-249->DbSessionProvider.acquire/close,DbCommandExecutor.query/execute/scalar,DbTransactionRunner.runare all sync. Same inmodular_api_postgres.Why this is a defect, not an idiomatic choice
An
async def execute()use case that calls a synchronous db repository performs blocking network I/O inside the asyncio event loop, degrading the concurrency of the whole ASGI server. TS and Dart contracts are already async (Promise/Future), so this is also a real parity gap specific to Python.Fix
Make the Python db contracts
async:DbSessionProvider,DbCommandExecutor,DbTransactionRunnerprotocols ->async def.DbTransactionContext/DbRepositoryContexthelper methods ->async.Notes