The Boltons library collection features a class for atomic file writes. 0.1.4 Feb 10, 2015 0.1.3 Feb 6, 2015 0.1.2.
Released:
Atomic file writes.
Atomic file writes.
Features that distinguish it from other similar libraries (see Alternatives and Credit):
Race-free assertion that the target file doesn’t yet exist. This can becontrolled with the overwrite parameter.
Windows support, although not well-tested. The MSDN resources are not veryexplicit about which operations are atomic. I’m basing my assumptions off acommentby Doug Crook, who appearsto be a Microsoft employee:
FAQ: Is MoveFileEx atomicFrequently asked question: Is MoveFileEx atomic if the existing and newfiles are both on the same drive?
The simple answer is “usually, but in some cases it will silently fall-backto a non-atomic method, so don’t count on it”.
The implementation of MoveFileEx looks something like this: […]
The problem is if the rename fails, you might end up with a CopyFile, whichis definitely not atomic.
If you really need atomic-or-nothing, you can try callingNtSetInformationFile, which is unsupported but is much more likely to beatomic.
Simple high-level API that wraps a very flexible class-based API.
Consistent error handling across platforms.
It uses a temporary file in the same directory as the given path. This ensuresthat the temporary file resides on the same filesystem.
The temporary file will then be atomically moved to the target location: OnPOSIX, it will use rename if files should be overwritten, otherwise acombination of link and unlink. On Windows, it uses MoveFileEx throughstdlib’s ctypes with the appropriate flags.
Note that with link and unlink, there’s a timewindow where the filemight be available under two entries in the filesystem: The name of thetemporary file, and the name of the target file.
Also note that the permissions of the target file may change this way. In somesituations a chmod can be issued without any concurrency problems, butsince that is not always the case, this library doesn’t do it by itself.
On POSIX, fsync is invoked on the temporary file after it is written (toflush file content and metadata), and on the parent directory after the file ismoved (to flush filename).
fsync does not take care of disks’ internal buffers, but there don’t seemto be any standard POSIX APIs for that. On OS X, fcntl is used withF_FULLFSYNC instead of fsync for that reason.
On Windows, _commitis used, but there are no guarantees about disk internal buffers.
Atomicwrites is directly inspired by the following libraries (and shares aminimal amount of code):
Ccleaner pro crack. Other alternatives to atomicwrites include: Free blu ray player.
1.4.0
1.3.0
1.2.1
1.2.0
1.1.5
1.1.0
1.0.0
0.1.9
0.1.8
0.1.7
0.1.6
https://edvse.over-blog.com/2021/01/free-engineering-drawing-program-for-mac.html. 0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size atomicwrites-1.4.0-py2.py3-none-any.whl (6.8 kB) | File type Wheel | Python version py2.py3 | Upload date | Hashes |
Filename, size atomicwrites-1.4.0.tar.gz (11.8 kB) | File type Source | Python version None | Upload date | Hashes |
Algorithm | Hash digest |
---|---|
SHA256 | 6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197 |
MD5 | acc030856f5d16b2aac6dcc74d1b36a4 |
BLAKE2-256 | 2ca0da5f49008ec6e9a658dbf5d7310a4debd397bce0b4db03cf8a410066bb87 |
Algorithm | Hash digest |
---|---|
SHA256 | ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a |
MD5 | b5cc15c8f9f180a48665f9aacf91d817 |
BLAKE2-256 | 558d74a75635f2c3c914ab5b3850112fd4b0c8039975ecb320e4449aa363ba54 |