views:

28

answers:

3

Hello, 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?

Sorry for how vague the question is, I've never had to think about this sort of issue before. Thank you for any advice you have.

+1  A: 

You should really check this out: http://blogs.msdn.com/b/ntdebugging/archive/2007/06/09/how-windows-shuts-down.aspx (How Windows Shuts Down)

Soulseekah
+1  A: 

use atexit module

singularity
A: 

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"
lunixbochs