mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 16:28:11 +00:00
Fix AsyncSession handling after breaking changes in FastAPI 0.74.0
See https://github.com/tiangolo/fastapi/releases/tag/0.74.0 for details.
This commit is contained in:
parent
9b39bfb845
commit
8975f63e2f
@ -24,11 +24,11 @@ from gns3server.db.repositories.base import BaseRepository
|
|||||||
|
|
||||||
async def get_db_session(request: HTTPConnection) -> AsyncSession:
|
async def get_db_session(request: HTTPConnection) -> AsyncSession:
|
||||||
|
|
||||||
session = AsyncSession(request.app.state._db_engine, expire_on_commit=False)
|
async with AsyncSession(request.app.state._db_engine, expire_on_commit=False) as session:
|
||||||
try:
|
try:
|
||||||
yield session
|
yield session
|
||||||
finally:
|
finally:
|
||||||
await session.close()
|
await session.close()
|
||||||
|
|
||||||
|
|
||||||
def get_repository(repo: Type[BaseRepository]) -> Callable:
|
def get_repository(repo: Type[BaseRepository]) -> Callable:
|
||||||
|
Loading…
Reference in New Issue
Block a user