Skip to main content
https://travis-ci.org/joanvila/aioredlock.svg?branch=master https://codecov.io/gh/joanvila/aioredlock/branch/master/graph/badge.svg https://badge.fury.io/py/aioredlock.svg

The asyncio redlock algorithm implementation.

Redlock and asyncio

The redlock algorithm is a distributed lock implementation for Redis. There are many implementations of it in several languages. In this case, this is the asyncio compatible implementation for python 3.5+.

Usage

from aioredlock import Aioredlock

# Define a list of connections to your Redis instances:
redis_instances = [
  {'host': 'localhost', 'port': 6379}
]

# Create a lock manager:
lock_manager = Aioredlock(redis_instances)

# Try to acquire the lock:
lock = await lock_manager.lock("resource_name")

# Release the lock:
await lock_manager.unlock(lock)

# Clear the connections with Redis
await lock_manager.destroy()

How it works

The Aioredlock constructor takes a list of connections (host and port) where the Redis instances are running as a required parameter. In order to acquire the lock, the lock function should be called. If the lock operation is successful, lock.valid will be true.

>From that moment, the lock is valid until the unlock function is called or when the 10 seconds timeout is reached.

In order to clear all the connections with Redis, the lock_manager destroy method can be called.

To-do

  • Allow the user to set a desired lock timeout with 10 seconds default

  • Raise an exception if the lock cannot be obtained so no need to check for lock.valid

  • Handle/encapsulate aioredis exceptions when performing operations

  • Expire the lock valid attribute according to the lock validity in a safe way if possible

  • Lock extension

Metadata

Release files for aioredlock 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aioredlock 0.1.1
File Size Uploaded Provenance
aioredlock-0.1.1.tar.gz 4.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aioredlock 0.1.1
File Interpreter ABI Platform
aioredlock-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / aioredlock-0.1.1.tar.gz

Download URL aioredlock-0.1.1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2b15c9515fc0143bb8c26de059c04f839e4af3ff421741042558a5f540e188f6
BLAKE2b-256 checksum
How to use checksums
3c08ab0a71102aafe2cffe5f82aa9026908411716e5292d2fc4299c16437409f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / aioredlock-0.1.1-py3-none-any.whl

Download URL aioredlock-0.1.1-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
114bdf25d367e2e4cf855e48e5477badb89eefdcea583de757044635cb4afce2
BLAKE2b-256 checksum
How to use checksums
e3ecb774f98fccdd7e4bf8c1b786f9ef4d73083b12fee2b43de162243b11e34e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for aioredlock 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page