https://github.com/pykit3/k3zkutil
Some helper function to make life easier with zookeeper.
https://github.com/pykit3/k3zkutil
python zookeeper
Last synced: 4 months ago
JSON representation
Some helper function to make life easier with zookeeper.
- Host: GitHub
- URL: https://github.com/pykit3/k3zkutil
- Owner: pykit3
- License: mit
- Created: 2021-08-12T04:00:15.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-08-28T12:39:07.000Z (9 months ago)
- Last Synced: 2025-10-28T10:59:25.477Z (7 months ago)
- Topics: python, zookeeper
- Language: Python
- Homepage: https://blog.openacid.com
- Size: 53.7 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# k3zkutil
[](https://github.com/pykit3/k3zkutil/actions/workflows/python-package.yml)
[](https://k3zkutil.readthedocs.io/en/stable/?badge=stable)
[](https://pypi.org/project/k3zkutil)
Some helper function to make life easier with zookeeper.
k3zkutil is a component of [pykit3] project: a python3 toolkit set.
Some helper function to make life easier with zookeeper.
# Install
```
pip install k3zkutil
```
# Synopsis
```python
from k3zkutil import config
"""
config.zk_acl # (('xp', '123', 'cdrwa'), ('foo', 'bar', 'rw'))
config.zk_auth # ('digest', 'xp', '123')
config.zk_hosts # '127.0.0.1:2181'
config.zk_node_id # 'web-01'
config.zk_lock_dir # 'lock/'
"""
with k3zkutil.ZKLock('foo_lock',
zkconf=dict(
hosts='127.0.0.1:2181',
acl=(('xp', '123', 'cdrwa'),),
auth=('digest', 'xp', '123'),
node_id='web-3',
lock_dir='my_locks/'
)):
print("do something")
lock = k3zkutil.ZKLock('foo')
try:
for holder, ver in lock.acquire_loop(timeout=3):
print('lock is currently held by:', holder, ver)
print('lock is acquired')
except k3zkutil.LockTimeout as e:
print('timeout to acquire "foo"')
```
# Author
Zhang Yanpo (张炎泼)
# Copyright and License
The MIT License (MIT)
Copyright (c) 2015 Zhang Yanpo (张炎泼)
[pykit3]: https://github.com/pykit3