Skip to content

Commit eb3db50

Browse files
committed
lock simlify
1 parent fc69f5c commit eb3db50

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

ydb/aio/coordination/lock.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def __init__(self, node, name: str):
1717
self._node = node
1818
self._name = name
1919

20-
self._count: int = 1
21-
self._timeout_millis: int = node._timeout_millis
20+
self._count = 1
21+
self._timeout_millis = node._timeout_millis
2222

2323
async def acquire(self):
2424
resp = await self._try_acquire()
@@ -27,21 +27,10 @@ async def acquire(self):
2727
await self._create_if_not_exists()
2828
resp = await self._try_acquire()
2929

30-
if resp.status == StatusCode.SUCCESS:
31-
return self
32-
33-
if (
34-
resp.status
35-
in (
36-
StatusCode.ALREADY_EXISTS,
37-
StatusCode.PRECONDITION_FAILED,
38-
StatusCode.SESSION_BUSY,
39-
)
40-
or resp.status == 400040
41-
):
42-
return self
30+
if resp.status != StatusCode.SUCCESS:
31+
raise issues.Error(f"Failed to acquire lock {self._name}: {resp.status}")
4332

44-
raise issues.Error(f"Failed to acquire lock {self._name}: {resp.status}")
33+
return self
4534

4635
async def release(self):
4736
req = ReleaseSemaphore(

0 commit comments

Comments
 (0)