Nick
Nick

Reputation: 5

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?

Upvotes: 0

Views: 136

Answers (3)

soulseekah
soulseekah

Reputation: 9162

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

Upvotes: 1

lunixbochs
lunixbochs

Reputation: 22415

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"

Upvotes: 0

mouad
mouad

Reputation: 70021

use atexit module

Upvotes: 1

Related Questions