rebase
This commit is contained in:
@@ -339,8 +339,18 @@ def _format_sse(evt: dict[str, str]) -> str:
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def _session_scope():
|
||||
"""Open a fresh DB session for the background task."""
|
||||
"""Open a fresh DB session for the background task.
|
||||
|
||||
Must be used as: async with _session_scope() as bg_db: ...
|
||||
The @asynccontextmanager decorator is required — without it, an
|
||||
`async def` with `yield` returns an async generator, which does NOT
|
||||
support `async with`.
|
||||
"""
|
||||
from app.db import get_sessionmaker
|
||||
|
||||
sm = get_sessionmaker()
|
||||
|
||||
Reference in New Issue
Block a user