Skip to main content

Some helper function to make life easier with zookeeper.

Project description

k3zkutil

Action-CI Build Status Documentation Status Package

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

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 (张炎泼) drdr.xp@gmail.com

Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com

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

k3zkutil-0.1.0.tar.gz (15.7 kB view hashes)

Uploaded Source

Built Distribution

k3zkutil-0.1.0-py3-none-any.whl (18.0 kB view hashes)

Uploaded Python 3

Supported by

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