Eryk Sun added the comment: > the lack of Windows' os.rename() atomicity
rename/replace is two system calls: NtOpenFile to get a handle for the source file and NtSetInformationFile to rename it. The difference is only that replace() sets the ReplaceIfExists field in the FileRenameInformation. The rename operation should be atomic. If the source file is already open without delete/rename sharing, opening it to rename it will fail with sharing violation. After the handle is open, another thread could set the delete disposition on the source file (i.e. flag it to be unlinked), which will cause the rename to fail with access denied. The relative timing of the threads is the difference between getting a FileNotFoundError versus a PermissionError. The other thread could also open a handle to the destination file at this point, which also causes the rename to fail with access denied, but that's no different from what would happen if it were already open. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26362> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com