Skip to content

Commit

Permalink
ensured db connection closure in get_db_session method
Browse files Browse the repository at this point in the history
  • Loading branch information
siwonKH committed Nov 6, 2023
1 parent deed2d6 commit 59bf219
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bus_boarding_api/db/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ async def get_db_session(request: Request) -> AsyncGenerator[AsyncSession, None]

try: # noqa: WPS501
yield session
except Exception as e:
# logger.error(f"An error occurred: {e}")
await session.rollback()
raise
finally:
await session.commit()
await session.close()

0 comments on commit 59bf219

Please sign in to comment.