Keep trying until session obtained

This commit is contained in:
Jeremy Zhang 2018-03-25 21:26:53 +00:00
parent 1e43f607b6
commit 5364cf9004

View File

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