开发者

process closing while saving a file - Python - Windows XP

I'm working on a project for school where e-mails will be pulled from an inbox and downloaded to different locations depending on how things are parsed. The language I'm writing in is Python, and the environment it will be run on is Windows XP. The idea is that the program will run in the background with no interaction from the user until they basically shutdown their computer. A concern I had is what this will mean if they shut it down while a file is in the process of being saved, and what I can do to handle it.

开发者_如何学运维

Will it just be a file.part thing? Will the shutdown throw the "Waiting to close X application" message and finish saving before terminating on its own?


use atexit module


You should really check this out: Link (How Windows Shuts Down)


easy crossplatform/crosslanguage way of handling partial file saving:

  1. save to a temporary filename like "file.ext.part"
  2. after you're done saving, rename to "file.ext"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜