Skip to main content

A simple distributed lock based on redis.

Project description

Redis based distributed lock

This is a simple distributed lock based on redis. It needs asyncio, otherwise it will not work!

You can install it simply with pip install rdlock_py

Usage

1, setup a redis client factory.

2, get a mutex and manage it with the context manager.

from rdlock import RDLockFactory, LockError, LockTimeout

factory = RDLockFactory("redis://:@localhost:30000/0")

try:
    async with factory.get_mutex("test_mutex", "my_owner", 1.0):
        # do your work here
        pass
except LockTimeout:
    print("failed to get lock in several seconds...")
except LockError:
    print("Something wrong when communicating with redis")

Test

Use the uv run pytest will automatically test all cases.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rdlock_py-0.1.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rdlock_py-0.1.3-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file rdlock_py-0.1.3.tar.gz.

File metadata

  • Download URL: rdlock_py-0.1.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rdlock_py-0.1.3.tar.gz
Algorithm Hash digest
SHA256 86a5a2323b99004001bfc66997e8fd80577632e2cef53f977e1951ca2e10cec9
MD5 0972e4107117d6ad45a75c59e5c8af09
BLAKE2b-256 7bba5515022d3edf39b1fa9f1a26bede9dd34c365c995bea69db43077803923a

See more details on using hashes here.

File details

Details for the file rdlock_py-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: rdlock_py-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rdlock_py-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a90c5f6b35f89cccc4f69ae7e96d8325506b5c9b894e9a39db84d98c21b7e9cf
MD5 1725c824e931f6ad75169fbc5f6ee980
BLAKE2b-256 2d12be24b80209b6b86a0d528f8bdb487a059e5b1046b5ae8b99d4fcc07ce9ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page