Skip to content

Commit

Permalink
added lock upon creating a new Session
Browse files Browse the repository at this point in the history
  • Loading branch information
qcdyx committed Jan 11, 2024
1 parent f650561 commit d465ab0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/src/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ def start_session(self):
if global_session is not None and global_session.is_active:
self.logger.info("Database session reused.")
return global_session
lock.acquire()
global_session = Session(self.engine, autoflush=False)
self.logger.info("Singleton Database session started.")
except Exception as error:
raise Exception(f"Error creating database session: {error}")
finally:
lock.release()
return self.is_connected()


Expand Down

0 comments on commit d465ab0

Please sign in to comment.