有没有COMMIT模拟在Python中写入文件? [英] is there COMMIT analog in python for writing into a file?
问题描述
如果主进程没有完成时系统崩溃怎么办?有没有办法做一种提交一次,每...说 - 10分钟(我自己调用这个提交 - 不需要运行计时器)?是file.close()和open(文件,'a')唯一的方式,还是有更好的选择?
你应该可以使用 file.flush()
来做到这一点。
I have a file open for writing, and a process running for days -- something is written into the file in relatively random moments. My understanding is -- until I do file.close() -- there is a chance nothing is really saved to disk. Is that true?
What if the system crashes when the main process is not finished yet? Is there a way to do kind of commit once every... say -- 10 minutes (and I call this commit myself -- no need to run timer)? Is file.close() and open(file,'a') the only way, or there are better alternatives?
You should be able to use file.flush()
to do this.
这篇关于有没有COMMIT模拟在Python中写入文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!