Skip to main content

Writeable file object that atomically updates a file.

Project description

Writeable file object that atomically updates a file.

All writes will go to a temporary file. Call close() explicitly when you are done writing, and AtomicFile will rename the temporary copy to the original name, making the changes visible. If the object is destroyed without being closed, all your writes are discarded.

AtomicFile is friendly to with statement.

from atomicfile import AtomicFile

with AtomicFile("panic.txt", "w") as f:
    f.write(json.dumps(big_data_array_100MB, sort_keys=True, indent=4))


To install AtomicFile, simply:

pip install atomicfile

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for atomicfile, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size atomicfile-1.0.1.tar.gz (2.3 kB) File type Source Python version None Upload date Hashes View
Filename, size atomicfile-1.0.1-py3-none-any.whl (3.5 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page