Skip to main content

Python client for the etcd v3 API for python >= 3.8

Project description

pyetcd

version Supported Python Versions Downloads Downloads license

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

  1. Generate protos
make 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.7.tar.gz (169.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

etcd_sdk_python-0.0.7-py3-none-any.whl (52.8 kB view details)

Uploaded Python 3

File details

Details for the file etcd_sdk_python-0.0.7.tar.gz.

File metadata

  • Download URL: etcd_sdk_python-0.0.7.tar.gz
  • Upload date:
  • Size: 169.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for etcd_sdk_python-0.0.7.tar.gz
Algorithm Hash digest
SHA256 3eae8b16328a458dce8a4d39a835db666f31bc6f369117f6168c71bcd559a85d
MD5 70379caf1666cde9a281802b66d707f2
BLAKE2b-256 42b399c19e3d4e2d6b946e60ca4d7e6a2b260f444550406cf5cb6b78fff97024

See more details on using hashes here.

File details

Details for the file etcd_sdk_python-0.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for etcd_sdk_python-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 dc0eb417c06c6e4f94c370dd19c096309f7a10bc6c89730c4fd66edd53f3a62f
MD5 8e51b0c1e969298434eaa4c684fcbbe6
BLAKE2b-256 345764e3b980a1448254eb9160f69e22180f92563e4f030fc7595f7b64634e95

See more details on using hashes here.

Supported by

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