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
make genproto
Credits
Many thx to python-etcd3
Release files for etcd-sdk-python 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| etcd_sdk_python-0.0.7.tar.gz | 169.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| etcd_sdk_python-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 222.6 kB
Release files / etcd_sdk_python-0.0.7.tar.gz
| Download URL | etcd_sdk_python-0.0.7.tar.gz |
|---|---|
| Size | 169.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3eae8b16328a458dce8a4d39a835db666f31bc6f369117f6168c71bcd559a85d
|
|
BLAKE2b-256 checksum How to use checksums |
42b399c19e3d4e2d6b946e60ca4d7e6a2b260f444550406cf5cb6b78fff97024
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / etcd_sdk_python-0.0.7-py3-none-any.whl
| Download URL | etcd_sdk_python-0.0.7-py3-none-any.whl |
|---|---|
| Size | 52.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dc0eb417c06c6e4f94c370dd19c096309f7a10bc6c89730c4fd66edd53f3a62f
|
|
BLAKE2b-256 checksum How to use checksums |
345764e3b980a1448254eb9160f69e22180f92563e4f030fc7595f7b64634e95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|