Wait until got session

This commit is contained in:
Jeremy Zhang 2018-03-25 20:24:39 +00:00
parent 70b2b266c8
commit fa3d533354

View File

@ -33,7 +33,13 @@ class DatabaseInterface(object):
@contextmanager
def get_session(self) -> Session:
session = self._sessionmaker() # type: Session
got_session = False
while not got_session:
try:
session = self._sessionmaker() # type: Session
got_session = True
except:
pass
try:
yield session
session.commit()