<commit_before>=========================
    python-redis-lock
=========================

.. image:: https://secure.travis-ci.org/ionelmc/python-python-redis-lock.png?branch=master
    :alt: Build Status
    :target: http://travis-ci.org/ionelmc/python-python-redis-lock

.. image:: https://coveralls.io/repos/ionelmc/python-python-redis-lock/badge.png?branch=master
    :alt: Coverage Status
    :target: https://coveralls.io/r/ionelmc/python-python-redis-lock

.. image:: https://pypip.in/d/python-redis-lock/badge.png
    :alt: PYPI Package
    :target: https://pypi.python.org/pypi/python-redis-lock

.. image:: https://pypip.in/v/python-redis-lock/badge.png
    :alt: PYPI Package
    :target: https://pypi.python.org/pypi/python-redis-lock

Lock context manager implemented via redis SETNX/BLPOP.

Interface targeted to be exactly like `threading.Lock <docs.python.org/2/library/threading.html#threading.Lock>`_.

Usage
=====

Because we don't want to require users to share the lock instance across processes you will have to give them names. Eg::

    conn = StrictRedis()
    with redis_lock.Lock(conn, "name-of-the-lock"):
        print("Got the lock. Doing some work ...")
        time.sleep(5)

Eg::

    lock = redis_lock.Lock(conn, "name-of-the-lock")
    if lock.acquire(blocking=False):
        print("Got the lock.")
    else:
        print("Someone else has the lock.")

Features
========

* based on the standard SETNX recipe
* optional expiry
* no spinloops at acquire

Implementation
==============

``redis_lock`` will use 2 keys for each lock named ``<name>``: 

* ``lock:<name>`` - a string value for the actual lock
* ``lock-signal:<name>`` - a list value for signaling the waiters when the lock is released

This is how it works:

.. image:: https://raw.github.com/ionelmc/python-redis-lock/master/docs/redis-lock%20diagram.png
    :alt: python-redis-lock flow diagram

TODO
====

* ???

Requirements<commit_msg>Fix links.<commit_after>=========================
    python-redis-lock
=========================

.. image:: https://secure.travis-ci.org/ionelmc/python-redis-lock.png?branch=master
    :alt: Build Status
    :target: http://travis-ci.org/ionelmc/python-redis-lock

.. image:: https://coveralls.io/repos/ionelmc/python-redis-lock/badge.png?branch=master
    :alt: Coverage Status
    :target: https://coveralls.io/r/ionelmc/python-redis-lock

.. image:: https://pypip.in/d/python-redis-lock/badge.png
    :alt: PYPI Package
    :target: https://pypi.python.org/pypi/python-redis-lock

.. image:: https://pypip.in/v/python-redis-lock/badge.png
    :alt: PYPI Package
    :target: https://pypi.python.org/pypi/python-redis-lock

Lock context manager implemented via redis SETNX/BLPOP.

Interface targeted to be exactly like `threading.Lock <docs.python.org/2/library/threading.html#threading.Lock>`_.

Usage
=====

Because we don't want to require users to share the lock instance across processes you will have to give them names. Eg::

    conn = StrictRedis()
    with redis_lock.Lock(conn, "name-of-the-lock"):
        print("Got the lock. Doing some work ...")
        time.sleep(5)

Eg::

    lock = redis_lock.Lock(conn, "name-of-the-lock")
    if lock.acquire(blocking=False):
        print("Got the lock.")
    else:
        print("Someone else has the lock.")

Features
========

* based on the standard SETNX recipe
* optional expiry
* no spinloops at acquire

Implementation
==============

``redis_lock`` will use 2 keys for each lock named ``<name>``:

* ``lock:<name>`` - a string value for the actual lock
* ``lock-signal:<name>`` - a list value for signaling the waiters when the lock is released

This is how it works:

.. image:: https://raw.github.com/ionelmc/python-redis-lock/master/docs/redis-lock%20diagram.png
    :alt: python-redis-lock flow diagram

TODO
====

* ???

Requirements
{'fraction_non_alphanumeric': 0.17455775234131113, 'fraction_numerical': 0.0026014568158168575, 'mean_word_length': 3.588305489260143, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2694559', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1281, 'n_words': 306}