Skip to main content

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

Project description

pyetcd3

version Supported Python Versions Downloads Downloads license

Python client for the etcd API v3, supported python >= 3.7, under active maintenance

Install

pip install pyetcd3-sdk

Differences from python-etcd3 and pyetcd

This package is a maintained fork of pyetcd with the following key improvements:

  • Updated grpcio version and support for etcd authentication (username/password).
  • Automatic token refresh to maintain authenticated sessions without manual reconnection.

These enhancements make pyetcd3-sdk more suitable for production environments that require secure, long-running connections to etcd clusters.

Basic usage:

import pyetcd3

etcd = pyetcd3.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)

Credits

Many thx to python-etcd3 and pyetcd

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

pyetcd3_sdk-1.0.0.tar.gz (71.0 kB view details)

Uploaded Source

Built Distribution

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

pyetcd3_sdk-1.0.0-py3-none-any.whl (53.4 kB view details)

Uploaded Python 3

File details

Details for the file pyetcd3_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: pyetcd3_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 71.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for pyetcd3_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b064a3a5a575486120672606c65da92221c20df7d696df362d262b9888a856d9
MD5 0b97751019c0bc6a6222dea4d226826f
BLAKE2b-256 754539e65d6b836ce18d09f782c7a67010f66475626ce69239f7aaadaab5903b

See more details on using hashes here.

File details

Details for the file pyetcd3_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyetcd3_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 53.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for pyetcd3_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e0b6c2ec1d8fddd804034acfb13906848ae3b70b067946ce4ee5e965a1e4f5c
MD5 7a77fa400ae1751d63e318b548d559cf
BLAKE2b-256 fa6756cffb88a5e65904096d3897b74d2183b81a69fc61f640a9c0b06a5a7ab1

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