Skip to content

Commit 0adaa9e

Browse files
committedJul 28, 2015
Fix locking docs, bump version
1 parent 983a6ba commit 0adaa9e

File tree

2 files changed

+12
-28
lines changed

2 files changed

+12
-28
lines changed
 

‎README.rst

+11-27
Original file line numberDiff line numberDiff line change
@@ -108,41 +108,25 @@ Locking module
108108
# Initialize the lock object:
109109
# NOTE: this does not acquire a lock yet
110110
client = etcd.Client()
111-
lock = client.get_lock('/customer1', ttl=60)
111+
lock = etcd.Lock(client, 'my_lock_name')
112112
113113
# Use the lock object:
114-
lock.acquire(timeout=30) #returns if lock could not be acquired within 30 seconds
115-
lock.is_locked() # True
116-
lock.renew(60)
117-
lock.release()
118-
lock.is_locked() # False
114+
lock.acquire(blocking=True, # will block until the lock is acquired
115+
lock_ttl=None) # lock will live until we release it
116+
lock.is_acquired() #
117+
lock.acquire(lock_ttl=60) # renew a lock
118+
lock.release() # release an existing lock
119+
lock.is_acquired() # False
119120
120121
# The lock object may also be used as a context manager:
121122
client = etcd.Client()
122-
lock = client.get_lock('/customer1', ttl=60)
123-
with lock as my_lock:
123+
with etcd.Lock('customer1') as my_lock:
124124
do_stuff()
125-
lock.is_locked() # True
126-
lock.renew(60)
127-
lock.is_locked() # False
125+
my_lock.is_acquired() # True
126+
my_lock.acquire(lock_ttl = 60)
127+
my_lock.is_acquired() # False
128128
129129
130-
Leader Election module
131-
~~~~~~~~~~~~~~~~~~~~~~
132-
133-
.. code:: python
134-
135-
# Set a leader object with a name; if no name is given, the local hostname
136-
# is used.
137-
# Zero or no ttl means the leader object is persistent.
138-
client = etcd.Client()
139-
client.election.set('/mysql', name='foo.example.com', ttl=120, timeout=30) # returns the etcd index
140-
141-
# Get the name
142-
print(client.election.get('/mysql')) # 'foo.example.com'
143-
# Delete it!
144-
print(client.election.delete('/mysql', name='foo.example.com'))
145-
146130
Get machines in the cluster
147131
~~~~~~~~~~~~~~~~~~~~~~~~~~~
148132

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
NEWS = open(os.path.join(here, 'NEWS.txt')).read()
77

88

9-
version = '0.3.3'
9+
version = '0.4.0'
1010

1111
install_requires = [
1212
'urllib3>=1.7'

0 commit comments

Comments
 (0)
Please sign in to comment.