Skip to content

Commit 1a29afa

Browse files
committed
handle watchtimeout
1 parent c6407b6 commit 1a29afa

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

etcd3/locks.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import time
33
import uuid
44

5-
from etcd3 import events
5+
from etcd3 import events, exceptions
66

77

88
class Lock(object):
@@ -94,8 +94,11 @@ def _try_acquire(self):
9494
return False
9595

9696
def _wait_delete_event(self, timeout):
97-
event_iter, cancel = self.etcd_client.watch(
98-
self.key, start_revision=self.revision + 1)
97+
try:
98+
event_iter, cancel = self.etcd_client.watch(
99+
self.key, start_revision=self.revision + 1)
100+
except exceptions.WatchTimedOut:
101+
return
99102

100103
if timeout is not None:
101104
timer = threading.Timer(timeout, cancel)

0 commit comments

Comments
 (0)