Skip to content

Commit

Permalink
fix: remove scoped session since fastapi reuse threads, breaking thre…
Browse files Browse the repository at this point in the history
…ad local sessions
  • Loading branch information
lchen-2101 committed Jan 8, 2025
1 parent e8fb7aa commit ef34b9c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/regtech_user_fi_management/entities/engine/engine.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.orm import sessionmaker
from regtech_user_fi_management.config import settings

engine = create_engine(str(settings.inst_conn), echo=settings.db_logging).execution_options(
schema_translate_map={None: settings.inst_db_schema}
)
SessionLocal = scoped_session(sessionmaker(engine, expire_on_commit=False))
SessionLocal = Session = sessionmaker(engine, expire_on_commit=False)


def get_session():
session = SessionLocal()
try:
with Session() as session:
yield session
finally:
session.close()

0 comments on commit ef34b9c

Please sign in to comment.