Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is os.replace() atomic on Windows?

Tags:

python

In the docs it says that replacing files are guaranteed to be atomic on POSIX systems. Does this mean that it's not atomic on Windows?

like image 652
Highflyer108 Avatar asked Aug 15 '18 15:08

Highflyer108


Video Answer


1 Answers

As visible in this thread the atomic replace functionality for windows has been added for version 3.3.

The patch is visible here.

In the background MoveFileEx with when nessesary the MOVEFILE_REPLACE_EXISTING flag added is called.

MoveFileEx is the same method as the openjdk calls. I can't find any documentation stating it is atomic, but the community seems to rely on it.

like image 79
NtFreX Avatar answered Sep 22 '22 02:09

NtFreX