more robust disposing of database session

avoid spamming the log with debug messages from libraries
This commit is contained in:
Daniel Pavel
2019-07-14 14:44:48 +03:00
parent be64961de5
commit a836df9a5a
7 changed files with 33 additions and 28 deletions
+7 -9
View File
@@ -407,16 +407,14 @@ def setup_db(config):
def dispose():
global session
engine = None
if session:
engine = session.bind
try: session.close()
except: pass
session = None
if engine:
try: engine.dispose()
old_session = session
session = None
if old_session:
try: old_session.close()
except: pass
if old_session.bind:
try: old_session.bind.dispose()
except: pass
for attr in list(Books.__dict__.keys()):
if attr.startswith("custom_column_"):