From 9aa599f9d2c15e76b45b0c21435248257983cd4f Mon Sep 17 00:00:00 2001 From: shortcutme Date: Mon, 18 Mar 2019 03:32:42 +0100 Subject: [PATCH] Close and commit all db at exit --- src/Db/Db.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Db/Db.py b/src/Db/Db.py index 044dc347..89dae460 100644 --- a/src/Db/Db.py +++ b/src/Db/Db.py @@ -4,6 +4,8 @@ import time import logging import re import os +import atexit + import gevent from Debug import Debug @@ -35,8 +37,13 @@ def dbCommitCheck(): db.need_commit = False time.sleep(0.1) +def dbCloseAll(): + for db in opened_dbs[:]: + db.close() + gevent.spawn(dbCleanup) gevent.spawn(dbCommitCheck) +atexit.register(dbCloseAll) class Db(object):