From 8fccb674cb2142905a60a877e2ce9be729553559 Mon Sep 17 00:00:00 2001 From: MichealCloud <1125107413@qq.com> Date: Wed, 13 Jun 2018 12:49:33 +0800 Subject: [PATCH] Update lock.py Locks can not be freed after multiple acquire functions are executed in single case mode --- etcd3gw/lock.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/etcd3gw/lock.py b/etcd3gw/lock.py index 3de9ae7..1567102 100644 --- a/etcd3gw/lock.py +++ b/etcd3gw/lock.py @@ -30,7 +30,7 @@ def __init__(self, name, ttl=DEFAULT_TIMEOUT, client=None): self.client = client self.key = LOCK_PREFIX + self.name self.lease = None - self._uuid = None + self._uuid = str(uuid.uuid1()) @property def uuid(self): @@ -40,7 +40,6 @@ def uuid(self): def acquire(self): """Acquire the lock.""" self.lease = self.client.lease(self.ttl) - self._uuid = str(uuid.uuid1()) base64_key = _encode(self.key) base64_value = _encode(self._uuid)