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.0a5.tar.gz (65.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: aetcd3-0.1.0a5.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.0a5.tar.gz
Algorithm Hash digest
SHA256 4ff4f5b719a6f07e6d40fcd5c86beffb6e0952381235a881d1fca965252cb1e1
MD5 ae88dd6ee13d7deacdfd04d11f788c8d
BLAKE2b-256 a8ed1ce41d74665fb256f2dc970a1070e2873a6b6d1f26826da85c099fdd4022

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aetcd3-0.1.0a5-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.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 ecdebc5f961d7d59c89cdd4211fdd74c576496a4007663ce477ca5f208b085f1
MD5 d7738bb186898d5ea2542d079156d3a6
BLAKE2b-256 0d416ab2258117a20bb4611d4823bbf7bea2afb231a9fb037d00d6550c547560

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