How to safely maintain a status file

alex23 wuwei23 at
Tue Jul 10 04:04:17 CEST 2012

On Jul 10, 6:24 am, John Nagle <na... at> wrote:
> That's because you're using the wrong approach. See how to use
> ReplaceFile under Win32:

I'm not convinced ReplaceFile is atomic:

"The ReplaceFile function combines several steps within a single
function. An application can call ReplaceFile instead of calling
separate functions to save the data to a new file, rename the original
file using a temporary name, rename the new file to have the same name
as the original file, and delete the original file."

About the best you can get in Windows, I think, is MoveFileTransacted,
but you need to be running Vista or later:

I agree with your suggestion of using something transactional that
isn't bound to later Window versions, though.

More information about the Python-list mailing list