aiteamutils 0.2.47__py3-none-any.whl → 0.2.48__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
aiteamutils/database.py CHANGED
@@ -1020,28 +1020,28 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
1020
1020
  source_function="get_db"
1021
1021
  )
1022
1022
 
1023
- session = None
1024
1023
  try:
1025
- async with db_service.get_session() as session:
1026
- if session is None:
1027
- raise CustomException(
1028
- ErrorCode.DB_CONNECTION_ERROR,
1029
- detail="Failed to create database session",
1030
- source_function="get_db"
1031
- )
1024
+ session = db_service.get_session()
1025
+ if session is None:
1026
+ raise CustomException(
1027
+ ErrorCode.DB_CONNECTION_ERROR,
1028
+ detail="Failed to create database session",
1029
+ source_function="get_db"
1030
+ )
1031
+
1032
+ # 세션이 유효한지 확인
1033
+ try:
1034
+ await session.execute(select(1))
1035
+ except Exception as e:
1036
+ await session.close()
1037
+ raise CustomException(
1038
+ ErrorCode.DB_CONNECTION_ERROR,
1039
+ detail="Database session is not valid",
1040
+ source_function="get_db",
1041
+ original_error=e
1042
+ )
1032
1043
 
1033
- # 세션이 유효한지 확인
1034
- try:
1035
- await session.execute(select(1))
1036
- except Exception as e:
1037
- raise CustomException(
1038
- ErrorCode.DB_CONNECTION_ERROR,
1039
- detail="Database session is not valid",
1040
- source_function="get_db",
1041
- original_error=e
1042
- )
1043
-
1044
- yield session
1044
+ yield session
1045
1045
  except Exception as e:
1046
1046
  if isinstance(e, CustomException):
1047
1047
  raise e
@@ -1052,8 +1052,7 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
1052
1052
  original_error=e
1053
1053
  )
1054
1054
  finally:
1055
- if session:
1056
- await session.close()
1055
+ await session.close()
1057
1056
 
1058
1057
  async def get_database_service() -> DatabaseService:
1059
1058
  """DatabaseService 의존성
@@ -5,7 +5,7 @@ from jose import JWTError, jwt
5
5
  from sqlalchemy.ext.asyncio import AsyncSession
6
6
  import logging
7
7
 
8
- from .database import DatabaseServiceManager, get_db, get_database_service
8
+ from .database import DatabaseServiceManager, DatabaseService, get_db, get_database_service
9
9
  from .exceptions import CustomException, ErrorCode
10
10
  from .config import get_settings
11
11
 
@@ -56,23 +56,16 @@ 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
+ def _get_service(
60
+ db_service: DatabaseService = Depends(get_database_service),
61
+ session: AsyncSession = Depends(get_db)
62
+ ):
60
63
  try:
61
64
  repository_class, service_class = service_registry.get(name)
62
65
  repository = repository_class(db_service)
63
66
  service = service_class(repository, db_service)
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
-
67
+ service.session = session
68
+ return service
76
69
  except CustomException as e:
77
70
  raise e
78
71
  except Exception as e:
aiteamutils/version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  """버전 정보"""
2
- __version__ = "0.2.47"
2
+ __version__ = "0.2.48"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiteamutils
3
- Version: 0.2.47
3
+ Version: 0.2.48
4
4
  Summary: AI Team Utilities
5
5
  Project-URL: Homepage, https://github.com/yourusername/aiteamutils
6
6
  Project-URL: Issues, https://github.com/yourusername/aiteamutils/issues
@@ -4,13 +4,13 @@ aiteamutils/base_repository.py,sha256=qdwQ7Sj2fUqxpDg6cWM48n_QbwPK_VUlG9zTSem8iC
4
4
  aiteamutils/base_service.py,sha256=E4dHGE0DvhmRyFplh46SwKJOSF_nUL7OAsCkf_ZJF_8,24733
5
5
  aiteamutils/cache.py,sha256=07xBGlgAwOTAdY5mnMOQJ5EBxVwe8glVD7DkGEkxCtw,1373
6
6
  aiteamutils/config.py,sha256=OM_b7g8sqZ3zY_DSF9ry-zn5wn4dlXdx5OhjfTGr0TE,2876
7
- aiteamutils/database.py,sha256=xUvxSRG49AY5DIWkucKMsaMMtfg5GumgJRwwwiUXm5w,40173
8
- aiteamutils/dependencies.py,sha256=UC19hLf5LHM4fdqVQHo7fHxytD47lkXuiSQvU2Vd4s0,4827
7
+ aiteamutils/database.py,sha256=rEKuZ8_3eBjP1KpTNVgWrVLAtKX_IkZJzul2pa8bDlg,40075
8
+ aiteamutils/dependencies.py,sha256=0mNmZiPlA8wTj4cgmjGXs6y9kkIQ5RtLZHdEeHxyblo,4490
9
9
  aiteamutils/enums.py,sha256=ipZi6k_QD5-3QV7Yzv7bnL0MjDz-vqfO9I5L77biMKs,632
10
10
  aiteamutils/exceptions.py,sha256=_lKWXq_ujNj41xN6LDE149PwsecAP7lgYWbOBbLOntg,15368
11
11
  aiteamutils/security.py,sha256=KSZf3WJAlW0UXVM1GEHwuGy2x27UHwtMr8aq-GuIXZk,16016
12
12
  aiteamutils/validators.py,sha256=3N245cZFjgwtW_KzjESkizx5BBUDaJLbbxfNO4WOFZ0,7764
13
- aiteamutils/version.py,sha256=o2IXukuF7KexqFBwlqOtUGuZABgd7WMZRzbAfk0_sdU,42
14
- aiteamutils-0.2.47.dist-info/METADATA,sha256=BqLPd9L224PbbrWL3Z4zcblCVV3oRcarMpS3o2Iipb8,1718
15
- aiteamutils-0.2.47.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- aiteamutils-0.2.47.dist-info/RECORD,,
13
+ aiteamutils/version.py,sha256=QOuBXnrQHPfVpSFpLi9n2XtFYH6CXKSg3p-oiLspDBg,42
14
+ aiteamutils-0.2.48.dist-info/METADATA,sha256=9gDfB-4023TWWGai8JWqujsazybfHZPDqnzrc9equJw,1718
15
+ aiteamutils-0.2.48.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ aiteamutils-0.2.48.dist-info/RECORD,,