README.rst

Fasteners

https://travis-ci.org/harlowja/fasteners.png?branch=master Documentation Status <object data="https://img.shields.io/pypi/dm/fasteners.svg" type="image/svg+xml">Downloads</object> <object data="https://img.shields.io/pypi/v/fasteners.svg" type="image/svg+xml">Latest Version</object>

Overview

A python package that provides useful locks.

It includes the following.

Locking decorator

  • Helpful locked decorator (that acquires instance objects lock(s) and acquires on method entry and releases on method exit).

Reader-writer locks

  • Multiple readers (at the same time).
  • Single writers (blocking any readers).
  • Helpful read_locked and write_locked decorators.

Inter-process locks

  • Single writer using file based locking (these automatically release on process exit, even if __release__ or __exit__ is never called).
  • Helpful interprocess_locked decorator.

Generic helpers

  • A try_lock helper context manager that will attempt to acquire a given lock and provide back whether the attempt passed or failed (if it passes, then further code in the context manager will be ran with the lock acquired).