Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/db_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

engine = create_async_engine(
SQLALCHEMY_DATABASE_URL,
pool_size=15,
max_overflow=15,
pool_timeout=30,
pool_size=30,
max_overflow=20,
pool_timeout=60,
)
sync_engine = create_engine(SQLALCHEMY_DATABASE_URL)

Expand Down Expand Up @@ -96,12 +96,9 @@ async def __aenter__(self):

async def __aexit__(self, exc_type, exc_value, traceback):
try:
if exc_type is None:
# 2. If NO exception occurred, commit the transaction.
if not self.db.in_transaction() and exc_type is None:
await self.db.commit()
else:
# 3. If an exception DID occur, roll back the transaction.
elif not self.db.in_transaction():
await self.db.rollback()
finally:
# 4. ALWAYS close the session.
await self.db.close()