[Python-Dev] os.rename on windows
Raghuram Devarakonda
draghuram at gmail.com
Tue May 1 06:14:47 CEST 2007
On 4/30/07, Andrew Bennetts <andrew-pythondev at puzzling.org> wrote:
> Does MOVEFILE_REPLACE_EXISTING mean the rename over an existing file is actually
> atomic? I cannot find any MSDN docs that say so (and I've seen some that
> suggest to me that it probably isn't).
Even though MSDN docs do not say it explicitly, I found some
discussions claiming that MOVEFILE_REPLACE_EXISTING is atomic.
However, after seeing your comment, I did a more thorough search and I
too found some references claiming otherwise. As a last resort, I
checked cygwin documentation which claims that it's rename() is
POSIX.1 compliant. If I am not mistaken, POSIX.1 does require
atomicity so I am curious how rename() is implemented there. I checked
out the sources and I will try to find more about their
implementation.
I completely agree that without positive proof of atomicity, there is
no point in making this code change.
> Also, I assume this cannot replace files that are in use?
A simple test shows that it can indeed replace files that are open.
Thanks,
Raghu
More information about the Python-Dev
mailing list