Skip to main content

Django Kazoo Locks

example workflow Coverage Status

About

Django Kazoo Locks provides a utils for using Zookeeper locks through kazoo in Django applications.

Install

pip install django-kazoo-locks

Usage

Register app in INSTALLED_APPS and define following settings:

ZOOKEEPER_APP_NAMESPACE = 'some-unique-app-name'
ZOOKEEPER_HOSTS = ['10.32.96.201:2181']

Usage example:

lock = Lock('my-lock-{object_id}')
with lock(object_id=123):
    print('so alone')

try:
    with lock(object_id=123, timeout=9):
        print('so alone')
except LockTimeout:
    print('unable to lock after waiting for 9s')

try:
    with lock(object_id=123, blocking=False):
        print('so alone')
except Locked:
    print('unable to lock immediately')

Extras

Migrations

This package defines its version of the data migration command - migrate_with_kazoo. Thanks to this command it is possible to quickly and correctly perform data migration process in applications running simultaneously on many different hosts and using the same database. The command can be used independently or as a base class for the migrate command in your own application. The __init__ method of the defined class accepts the optional lock argument, which allows you to define your own kazoo_locks.locks.Lock object to protect the critical section of the migration.

License

The Django Kazoo Locks package is licensed under the FreeBSD License.

Release files for django-kazoo-locks 2.0.0

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

Source distribution (sdist)

Source distribution for django-kazoo-locks 2.0.0
File Size Uploaded
django-kazoo-locks-2.0.0.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-kazoo-locks 2.0.0
File Interpreter ABI Platform
django_kazoo_locks-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.5 kB

Release files / django-kazoo-locks-2.0.0.tar.gz

Download URL django-kazoo-locks-2.0.0.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
180a8d70ba779de5e093c0e84ba70b220448aba6ecd44e00128435e2cae4a631
BLAKE2b-256 checksum
How to use checksums
aec39ec5b8293811a874557f480dfd9e1a4f10077cb133b259e10aa5f8de06cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / django_kazoo_locks-2.0.0-py3-none-any.whl

Download URL django_kazoo_locks-2.0.0-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb7b589c14d40c25b05b46ae986ffdb3e0679349e8fd8bad1e2c2b73998ab8ac
BLAKE2b-256 checksum
How to use checksums
0dcadfdaecfc116a666779cb583939a7a932af6c0eb16d9f79317c41afd22ee2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

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