Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/datalib/atomicio

Atomic writes to files
https://github.com/datalib/atomicio

Last synced: 23 days ago
JSON representation

Atomic writes to files

Awesome Lists containing this project

README

        

|logo| AtomicIO
===============

.. image:: https://travis-ci.org/datalib/atomicio.svg?branch=master
:target: https://travis-ci.org/datalib/atomicio

A library for making atomic file writes. Basically it guarantees
that the data is not partially written to the file (hence corrupting
it in case an exception is raised) by writing to a temporary file
that gets renamed and deleted after writing.

.. code-block:: python

from atomicio.api import atomic_write
with atomic_write(path) as (r,w):
for item in r:
w.write(process(item))

There are many other libraries that provide this functionality in
Python. This library's approach and API is inspired by `fatomic`_
and `python-atomicwrites`_ respectively. So far atomicio has not
been tested on Windows but it shouldn't work because currently,
``os.rename`` does not work on already created files.

.. _fatomic: https://github.com/abarnert/fatomic
.. _python-atomicwrites: https://github.com/untitaker/python-atomicwrites
.. |logo| image:: https://raw.githubusercontent.com/datalib/atomicio/master/media/logo-small.png