Skip to main content

Django Zookeeper Locks

example workflow Coverage Status

About

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

Install

pip install django-zookeeper-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_zookeeper. 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 zookeeper_locks.locks.Lock object to protect the critical section of the migration.

License

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

Release files for django-zookeeper-locks 1.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-zookeeper-locks 1.0.0
File Size Uploaded
django-zookeeper-locks-1.0.0.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-zookeeper-locks 1.0.0
File Interpreter ABI Platform
django_zookeeper_locks-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.6 kB

Release files / django-zookeeper-locks-1.0.0.tar.gz

Download URL django-zookeeper-locks-1.0.0.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
16ef66ef7dc2cd674a3d119567d636b0861d674a6b8ec6ced09e9d218a0aefe4
BLAKE2b-256 checksum
How to use checksums
96db5815f8cda8ae1a626d096fbd25a5b3481ac707d519e33aa931a7016802c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / django_zookeeper_locks-1.0.0-py3-none-any.whl

Download URL django_zookeeper_locks-1.0.0-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d07aaac4c2109ebcd28626aefafeea3be884a53f7fdbbc1e83caf394e19c9d27
BLAKE2b-256 checksum
How to use checksums
54be9fee723f653c164c1da36d773c15dd755abb7bb9f362aae273a911444a09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

1.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