Skip to main content

A python client for etcd

Project description

python-etcd documentation

A python client for Etcd

Official documentation:



Install etcd

From source

$ python install


Create a client object

import etcd

client = etcd.Client() # this will create a client against etcd server running on localhost on port 4001
client = etcd.Client(port=4002)
client = etcd.Client(host='', port=4003)
client = etcd.Client(host='', port=4003, allow_redirect=False) # wont let you run sensitive commands on non-leader machines, default is true

Set a key

client.set('/nodes/n1', 1)
# with ttl
client.set('/nodes/n2', 2, ttl=4)  # sets the ttl to 4 seconds

Get a key


Delete a key


Test and set

client.test_and_set('/nodes/n2', 2, 4) # will set /nodes/n2 's value to 2 only if its previous value was 4

Watch a key'/nodes/n1') # will wait till the key is changed, and return once its changed

List sub keys

# List nodes in the cluster

# List keys under /subtree

Get machines in the cluster


Get leader of the cluster


Development setup

To create a buildout,

$ python
$ bin/buildout

to test you should have etcd available in your system path:

$ bin/test

to generate documentation,

$ cd docs
$ make

Release HOWTO

To make a release

  1. Update release date/version in NEWS.txt and
  2. Run ‘python sdist’
  3. Test the generated source distribution in dist/
  4. Upload to PyPI: ‘python sdist register upload’



Release data: 30-Nov-2013

  • SSL support
  • Added support for subdirectories in results.
  • Improve test
  • Added support for reconnections, allowing death node tolerance.


Release data: 30-Sep-2013

  • Allow fetching of multiple keys (sub-nodes)


Release date: 18-Sep-2013

  • Initial release

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for python-etcd, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size python-etcd-0.2.1.tar.gz (13.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page