aiteamutils 0.2.46__tar.gz → 0.2.47__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/PKG-INFO +1 -1
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/aiteamutils/database.py +4 -1
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/aiteamutils/dependencies.py +13 -3
- aiteamutils-0.2.47/aiteamutils/version.py +2 -0
- aiteamutils-0.2.46/aiteamutils/version.py +0 -2
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/.cursorrules +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/.gitignore +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/README.md +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/aiteamutils/__init__.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/aiteamutils/base_model.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/aiteamutils/base_repository.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/aiteamutils/base_service.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/aiteamutils/cache.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/aiteamutils/config.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/aiteamutils/enums.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/aiteamutils/exceptions.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/aiteamutils/security.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/aiteamutils/validators.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/pyproject.toml +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.47}/setup.py +0 -0
@@ -1020,6 +1020,7 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
|
1020
1020
|
source_function="get_db"
|
1021
1021
|
)
|
1022
1022
|
|
1023
|
+
session = None
|
1023
1024
|
try:
|
1024
1025
|
async with db_service.get_session() as session:
|
1025
1026
|
if session is None:
|
@@ -1042,6 +1043,8 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
|
1042
1043
|
|
1043
1044
|
yield session
|
1044
1045
|
except Exception as e:
|
1046
|
+
if isinstance(e, CustomException):
|
1047
|
+
raise e
|
1045
1048
|
raise CustomException(
|
1046
1049
|
ErrorCode.DB_CONNECTION_ERROR,
|
1047
1050
|
detail=f"Failed to get database session: {str(e)}",
|
@@ -1049,7 +1052,7 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
|
1049
1052
|
original_error=e
|
1050
1053
|
)
|
1051
1054
|
finally:
|
1052
|
-
if
|
1055
|
+
if session:
|
1053
1056
|
await session.close()
|
1054
1057
|
|
1055
1058
|
async def get_database_service() -> DatabaseService:
|
@@ -56,13 +56,23 @@ def get_service(name: str):
|
|
56
56
|
Returns:
|
57
57
|
Callable: 서비스 인스턴스를 반환하는 의존성 함수
|
58
58
|
"""
|
59
|
-
async def _get_service(db_service = Depends(get_database_service)
|
59
|
+
async def _get_service(db_service = Depends(get_database_service)):
|
60
60
|
try:
|
61
61
|
repository_class, service_class = service_registry.get(name)
|
62
62
|
repository = repository_class(db_service)
|
63
63
|
service = service_class(repository, db_service)
|
64
|
-
|
65
|
-
|
64
|
+
|
65
|
+
# 세션 생성 및 설정
|
66
|
+
async with db_service.get_session() as session:
|
67
|
+
if session is None:
|
68
|
+
raise CustomException(
|
69
|
+
ErrorCode.DB_CONNECTION_ERROR,
|
70
|
+
detail="Failed to create database session",
|
71
|
+
source_function="dependencies.get_service"
|
72
|
+
)
|
73
|
+
service.session = session
|
74
|
+
return service
|
75
|
+
|
66
76
|
except CustomException as e:
|
67
77
|
raise e
|
68
78
|
except Exception as e:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|