[issue8604] Adding an atomic FS write API
STINNER Victor
report at bugs.python.org
Wed Dec 21 20:15:09 CET 2011
STINNER Victor <victor.stinner at haypocalc.com> added the comment:
> I'm not sure about the best module to host this, though: os.path ?
Some OS don't provide atomic rename. If we only define a function when it is atomic (as we do in the posix module, only expose functions available on the OS), programs will have to write two versions of their function. I prefer to write a "best-effort" function, and so I consider that shutil is the best place for such function.
If this function requires a function specific to the OS, the specific function can be added to posix (or another module).
Example:
with shutil.write_file(filename) as f:
f.write("I hope it will be atomic!")
We need an "atomic rename file" function to implement "atomic write file": see #8828.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8604>
_______________________________________
More information about the Python-bugs-list
mailing list