Message292706
> 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. |
|
Date |
User |
Action |
Args |
2017-05-01 23:04:47 | eryksun | set | recipients:
+ eryksun, georg.brandl, gumnos, r.david.murray, ethan.furman, bignose, serhiy.storchaka |
2017-05-01 23:04:47 | eryksun | set | messageid: <1493679887.5.0.656808414435.issue26362@psf.upfronthosting.co.za> |
2017-05-01 23:04:47 | eryksun | link | issue26362 messages |
2017-05-01 23:04:47 | eryksun | create | |
|