Close and commit all db at exit
This commit is contained in:
parent
a5ce7e5a1f
commit
9aa599f9d2
1 changed files with 7 additions and 0 deletions
|
@ -4,6 +4,8 @@ import time
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import atexit
|
||||||
|
|
||||||
import gevent
|
import gevent
|
||||||
|
|
||||||
from Debug import Debug
|
from Debug import Debug
|
||||||
|
@ -35,8 +37,13 @@ def dbCommitCheck():
|
||||||
db.need_commit = False
|
db.need_commit = False
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
def dbCloseAll():
|
||||||
|
for db in opened_dbs[:]:
|
||||||
|
db.close()
|
||||||
|
|
||||||
gevent.spawn(dbCleanup)
|
gevent.spawn(dbCleanup)
|
||||||
gevent.spawn(dbCommitCheck)
|
gevent.spawn(dbCommitCheck)
|
||||||
|
atexit.register(dbCloseAll)
|
||||||
|
|
||||||
|
|
||||||
class Db(object):
|
class Db(object):
|
||||||
|
|
Loading…
Reference in a new issue