![]() See issue #8604: proposal of a new "with atomic_write(filename) as fp. ![]() It can be improved later by adding the support of better Windows functions. This implementation is atomic on POSIX, and not atomic on Windows. Note: os.rename() uses MoveFileW() on Windows. The documentation will give a list of OS on which the operation *is* atomic (eg. I don't think that it's possible to write an atomic rename (file) function for any OS, so it's only a "best effort" atomic function. "If the file is to be moved to a different volume, the function simulates the move by using the CopyFile and DeleteFile functions."), version >= Windows 2000 MoveFileEx() with MOVEFILE_REPLACE_EXISTING and MOVEFILE_WRITE_THROUGH flags: not atomic (eg. MoveFileTransacted(): atomic! version >= (Windows Vista, Windows Server 2008) Windows offers different functions depending on the version: Os.rename() is atomic on Linux, but on Windows it raises an error if the destination does already exist. ![]() Trundle, draghuram, eric.araujo, giampaolo.rodola, neologix, pitrou, python-dev, r.david.murray, tarek, techtonik, vstinnerĬreated on 23:41 by vstinner, last changed 21:13 by pitrou.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |