这样做有问题吗:
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+中断程序,即不会正确关闭?Cdumbdbm
dumbdbm.sync ()是否足以保证数据的安全性,还是.close()
绝对强制性的?