Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Latest commit

 

History

History
25 lines (14 loc) · 768 Bytes

README.rst

File metadata and controls

25 lines (14 loc) · 768 Bytes

AtomicFile

https://travis-ci.org/sashka/atomicfile.svg?branch=master

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))

Install

To install AtomicFile, simply:

pip install atomicfile