Python client for the etcd v3 API for python >= 3.8
Project description
pyetcd
Python client for the etcd API v3, supported python >= 3.7, under active maintenance
Install
pip install etcd-sdk-python
Basic usage:
import pyetcd
etcd = pyetcd.client()
etcd.get('foo')
etcd.put('bar', 'doot')
etcd.delete('bar')
# locks
lock = etcd.lock('thing')
lock.acquire()
# do something
lock.release()
with etcd.lock('doot-machine') as lock:
# do something
# transactions
etcd.transaction(
compare=[
etcd.transactions.value('/doot/testing') == 'doot',
etcd.transactions.version('/doot/testing') > 0,
],
success=[
etcd.transactions.put('/doot/testing', 'success'),
],
failure=[
etcd.transactions.put('/doot/testing', 'failure'),
]
)
# watch key
watch_count = 0
events_iterator, cancel = etcd.watch("/doot/watch")
for event in events_iterator:
print(event)
watch_count += 1
if watch_count > 10:
cancel()
# watch prefix
watch_count = 0
events_iterator, cancel = etcd.watch_prefix("/doot/watch/prefix/")
for event in events_iterator:
print(event)
watch_count += 1
if watch_count > 10:
cancel()
# recieve watch events via callback function
def watch_callback(event):
print(event)
watch_id = etcd.add_watch_callback("/anotherkey", watch_callback)
# cancel watch
etcd.cancel_watch(watch_id)
# recieve watch events for a prefix via callback function
def watch_callback(event):
print(event)
watch_id = etcd.add_watch_prefix_callback("/doot/watch/prefix/", watch_callback)
# cancel watch
etcd.cancel_watch(watch_id)
Dev
- Generate protos
tox -e genproto
Credits
Many thx to python-etcd3
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
etcd_sdk_python-0.0.6.tar.gz
(69.2 kB
view details)
Built Distribution
File details
Details for the file etcd_sdk_python-0.0.6.tar.gz
.
File metadata
- Download URL: etcd_sdk_python-0.0.6.tar.gz
- Upload date:
- Size: 69.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
bba3718ac38acefe5909f6e535b4d97391aded17beac4e015c41c50477413389
|
|
MD5 |
88b11f11d4d0b8bed194b9a8048a228e
|
|
BLAKE2b-256 |
bde46e5a6e4b6895bf0c499467d989ff26f4d1b66a4a9dd635a0fff85536086b
|
File details
Details for the file etcd_sdk_python-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: etcd_sdk_python-0.0.6-py3-none-any.whl
- Upload date:
- Size: 52.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
adfee0e27748dc54c3ada0b3512cb487c7bd97965df96a1b8c2a55754f4496be
|
|
MD5 |
a467e4bc1f36b9a1cc901c095b175bf5
|
|
BLAKE2b-256 |
abbea90e67c31604271b473418caeef2e60c5fbe5a3fa4b1ba2872638061fad7
|