Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /MTSWebServices_horizon /tests /fixtures /async_session.py
| from __future__ import annotations | |
| from typing import TYPE_CHECKING | |
| import pytest_asyncio | |
| from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker | |
| if TYPE_CHECKING: | |
| from sqlalchemy.ext.asyncio import AsyncEngine | |
| async def async_session_factory(async_engine: AsyncEngine): | |
| yield async_sessionmaker( | |
| bind=async_engine, | |
| class_=AsyncSession, | |
| expire_on_commit=False, | |
| ) | |
| async def async_session(async_session_factory: async_sessionmaker[AsyncSession]): | |
| session: AsyncSession = async_session_factory() | |
| try: | |
| yield session | |
| await session.commit() | |
| except Exception: | |
| await session.rollback() | |
| raise | |
| finally: | |
| await session.close() | |
Xet Storage Details
- Size:
- 791 Bytes
- Xet hash:
- dbf63744f86259be250a057755b90b2be4932e7858a112553de2e18cee7efae7
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.