aiteamutils 0.2.41__tar.gz → 0.2.42__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiteamutils
3
- Version: 0.2.41
3
+ Version: 0.2.42
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
@@ -47,8 +47,21 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
47
47
  CustomException: 세션 생성 실패 시
48
48
  """
49
49
  db_service = get_database_service()
50
+ if not db_service or not db_service.engine:
51
+ raise CustomException(
52
+ ErrorCode.DB_CONNECTION_ERROR,
53
+ detail="Database service or engine is not properly initialized",
54
+ source_function="get_db"
55
+ )
56
+
50
57
  try:
51
58
  async with db_service.get_session() as session:
59
+ if session is None:
60
+ raise CustomException(
61
+ ErrorCode.DB_CONNECTION_ERROR,
62
+ detail="Failed to create database session",
63
+ source_function="get_db"
64
+ )
52
65
  yield session
53
66
  except Exception as e:
54
67
  raise CustomException(
@@ -58,7 +71,7 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
58
71
  original_error=e
59
72
  )
60
73
  finally:
61
- if 'session' in locals():
74
+ if 'session' in locals() and session is not None:
62
75
  await session.close()
63
76
 
64
77
  def get_database_session(db: AsyncSession = Depends(get_db)) -> 'DatabaseService':
@@ -69,8 +82,26 @@ def get_database_session(db: AsyncSession = Depends(get_db)) -> 'DatabaseService
69
82
 
70
83
  Returns:
71
84
  DatabaseService: DatabaseService 인스턴스
85
+
86
+ Raises:
87
+ CustomException: 데이터베이스 세션이 유효하지 않은 경우
72
88
  """
73
- return DatabaseService(session=db)
89
+ if db is None:
90
+ raise CustomException(
91
+ ErrorCode.DB_CONNECTION_ERROR,
92
+ detail="Database session is not initialized",
93
+ source_function="get_database_session"
94
+ )
95
+
96
+ db_service = DatabaseService(session=db)
97
+ if db_service.db is None:
98
+ raise CustomException(
99
+ ErrorCode.DB_CONNECTION_ERROR,
100
+ detail="Failed to initialize database session",
101
+ source_function="get_database_session"
102
+ )
103
+
104
+ return db_service
74
105
 
75
106
  class DatabaseService:
76
107
  def __init__(
@@ -0,0 +1,2 @@
1
+ """버전 정보"""
2
+ __version__ = "0.2.42"
@@ -1,2 +0,0 @@
1
- """버전 정보"""
2
- __version__ = "0.2.41"
File without changes
File without changes
File without changes
File without changes