Skip to main content

Python asyncio based client for the etcd API v3

Project description

Build Status Coverage report Documentation PyPI Version Supported Python Versions License

Installation

$ python3 -m pip install aetcd3

Basic usage

import aetcd3

etcd = aetcd3.client()
await etcd.get('foo')
await etcd.put('bar', 'doot')
await etcd.delete('bar')

# locks
lock = etcd.lock('thing')
await lock.acquire()
# do something
await lock.release()

async with etcd.lock('doot-machine') as lock:
    # do something

# transactions
await 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 = await etcd.watch("/doot/watch")
async for event in events_iterator:
    print(event)
    watch_count += 1
    if watch_count > 10:
        await cancel()

# watch prefix
watch_count = 0
events_iterator, cancel = await etcd.watch_prefix("/doot/watch/prefix/")
async for event in events_iterator:
    print(event)
    watch_count += 1
    if watch_count > 10:
        await cancel()

# receive watch events via callback function
def watch_callback(event):
    print(event)

watch_id = await etcd.add_watch_callback("/anotherkey", watch_callback)

# cancel watch
await etcd.cancel_watch(watch_id)

# receive watch events for a prefix via callback function
def watch_callback(event):
    print(event)

Acknowledgements

This project is a fork of etcd3aio, which itself is a fork of python-etcd3. python-etcd3 was originally written by kragniz. asyncio suppport was contributed by hron and based on the previous work by gjcarneiro. Kudos to all the people involved in the projects.

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

aetcd3-0.1.0a6.tar.gz (65.2 kB view details)

Uploaded Source

Built Distribution

aetcd3-0.1.0a6-py3-none-any.whl (50.4 kB view details)

Uploaded Python 3

File details

Details for the file aetcd3-0.1.0a6.tar.gz.

File metadata

  • Download URL: aetcd3-0.1.0a6.tar.gz
  • Upload date:
  • Size: 65.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for aetcd3-0.1.0a6.tar.gz
Algorithm Hash digest
SHA256 c3189d64b1f69924d9a8e7203499d0da855c5af516976a0f71f06f6502720dc6
MD5 afee8a5874be95da402b48e7a55c8f5a
BLAKE2b-256 6ab5b10a3303892bfa4c4cb8eacb7749f9e2fa8cf873addc0e77eb180e87724a

See more details on using hashes here.

File details

Details for the file aetcd3-0.1.0a6-py3-none-any.whl.

File metadata

  • Download URL: aetcd3-0.1.0a6-py3-none-any.whl
  • Upload date:
  • Size: 50.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for aetcd3-0.1.0a6-py3-none-any.whl
Algorithm Hash digest
SHA256 156a7de21a625d6c774395b47bf241ea499a2d1d48eec8c68af439927bf83c8e
MD5 031dca559705fd5dd9e61978909f47ff
BLAKE2b-256 2fab767820fee4b24dc543252136758f330b542cc2f62c8fcba6256c6c802ae8

See more details on using hashes here.

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