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:
- save to a temporary filename like "file.ext.part"
- after you're done saving, rename to "file.ext"
精彩评论