是它做了一个问题:同步功能,但不关闭DBM
import time
import dumbdbm
db = dumbdbm.open('db.db', 'c')
# modify the persistent dict/"DB" here
db['foo'] = 'bar'
db.sync()
while True:
# doing other things, sometimes modifying the db + syncing with .sync()
time.sleep(1)
,并在休眠时间与CTRL + Ç打破程序,即dumbdbm
将无法正确关闭?
是dumbdbm.sync()足以保证数据的安全性,还是.close()
是绝对强制性的?
您可以在睡觉前关闭*。 –
@ScottHunter,它是我整个事情的简化代码。我修改了。 – Basj