Add session_scope context manager to manage session scope

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-23 00:21:09 -03:00
commit bb3257ed80

View file

@ -57,6 +57,16 @@ def get_session() -> Generator["Session", None, None]:
@contextmanager
def session_scope():
"""
Context manager for managing a session scope.
Yields:
session: The session object.
Raises:
Exception: If an error occurs during the session scope.
"""
session = next(get_session())
try:
yield session