Skip to content

Commit 5af007f

Browse files
author
Anderson Souza
committed
fix: use try/finally in get_db to preserve exception stack traces
1 parent 38302d7 commit 5af007f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

backend/app/api/deps.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919

2020

2121
def get_db() -> Generator[Session, None, None]:
22-
with Session(engine) as session:
22+
session = Session(engine)
23+
try:
2324
yield session
25+
finally:
26+
session.close()
2427

2528

2629
SessionDep = Annotated[Session, Depends(get_db)]

0 commit comments

Comments
 (0)