lavkach3
1from uuid import uuid42
3from .session import session, set_session_context, reset_session_context4
5
6def standalone_session(func):7async def _standalone_session(*args, **kwargs):8session_id = str(uuid4())9context = set_session_context(session_id=session_id)10
11try:12await func(*args, **kwargs)13except Exception as e:14await session.rollback()15raise e16finally:17await session.remove()18reset_session_context(context=context)19
20return _standalone_session21