skip to navigation
skip to content

Not Logged In

acidfile 1.2.0

ACID transaction with common files

Package Documentation

Latest Version: 1.2.1


`acidfile` module provides the ACIDFile object. This object can be used as a
regular file object but instead of write one copy of the data, it will write
several copies to disk in an ACID manner.

This algorithm was explained by `Elvis Pfützenreuter`_ in his blog post
`Achieving ACID transactions with common files`_.

Latest stable version can be found on `PyPI`_.

.. image::

.. image::
:alt: Latest PyPI version

.. image::
:alt: Number of PyPI downloads

`acidfile` is compatible with python 2.6, 2.7, 3.2, 3.3 and pypy


.. image::
:alt: Flattr this git repo


Latest version can be installed via `pip`

.. code-block:: bash

$ pip install --upgrade acidfile

Running the tests

Clone this repository and install the develop requirements.

.. code-block:: bash

$ git clone
$ cd acidfile
$ pip install -r requirements/develop.txt
$ python develop
$ tox

Usage examples

Basic usage

.. code-block:: python

>>> from acidfile import ACIDFile

>>> myfile = ACIDFile('/tmp/myfile.txt', 'w')
>>> myfile.write(b'Some important data.')
>>> myfile.close()

At the close invocation two copies will be written to disk: *myfile.txt.0* and
below *myfile.txt.1*. Each one will have an creation timestamp and a HMAC

.. code-block:: python

>>> myfile = ACIDFile('/tmp/myfile.txt', 'r')
>>> print
'Some important data.'
>>> myfile.close()

If any of the files is damaged due to turning off without proper shutdown or
disk failure, manipulation, etc. It will be detected by the internal HMAC and
the other's file data would be used instead.

.. note:: If you want to read an `acidfile`, never pass the full path of the
real file, instead use the file name that you use in the creation step.

| ✗ ACIDFile('/tmp/myfile.txt.0', 'r')
| ✗ ACIDFile('/tmp/myfile.txt.1', 'r')
| ✓ ACIDFile('/tmp/myfile.txt', 'r')

Context manager

ACIDFile can (and should) be used as a regular context manager:

.. code-block:: python

>>> with ACIDFile('/tmp/myfile.txt', 'w') as myfile:
... myfile.write(b'Some important data.')

Number of copies

The number of inner copies of the data can be configured through the **copies**

Checksum Key

The key used for compute and check the internal HMAC signature can be setted
by the **key** parameter.

It's recommended to change that key in order to protect against fraud, making
more difficult for a tamperer to put a fake file in place of the legitimate

.. _PyPI:
.. _Elvis Pfützenreuter:
.. _Achieving ACID transactions with common files:

.. This is your project NEWS file which will contain the release notes.
.. Example:
.. The content of this file, along with README.rst, will appear in your
.. project's PyPI page.



+ Python 2.6 support.
+ Added Python 3.2 and pypy to tox tests.
+ Added flattr button :D
* Fixed flake8 and pylint warnings.


+ Python 3 support.
+ Changed testing framework to `behave` because python 3 support.
+ Using `tox` for multiple python version testing.


* First stable release.
+ Documentation.


* Initial development.  
File Type Py Version Uploaded on Size
acidfile-1.2.0.tar.gz (md5) Source 2014-01-08 5KB
  • Downloads (All Versions):
  • 20 downloads in the last day
  • 92 downloads in the last week
  • 538 downloads in the last month