Skip to content

Commit 58028ad

Browse files
committed
fixed check of return codes
1 parent 4db396b commit 58028ad

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/service-library/src/servicelib/redis/_semaphore.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ async def release(self) -> None:
216216
result = status
217217

218218
if result == "released":
219-
assert exit_code == SCRIPT_BAD_EXIT_CODE # nosec
219+
assert exit_code == SCRIPT_OK_EXIT_CODE # nosec
220220
_logger.debug(
221221
"Released semaphore '%s' (instance: %s, count: %s, expired: %s)",
222222
self.key,
@@ -227,7 +227,7 @@ async def release(self) -> None:
227227
else:
228228
# Instance wasn't in the semaphore set - this shouldn't happen
229229
# but let's handle it gracefully
230-
assert exit_code == SCRIPT_OK_EXIT_CODE # nosec
230+
assert exit_code == SCRIPT_BAD_EXIT_CODE # nosec
231231
raise SemaphoreNotAcquiredError(name=self.key)
232232

233233
async def _try_acquire(self) -> bool:

packages/service-library/src/servicelib/redis/lua/release_semaphore.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ local score = redis.call('ZSCORE', semaphore_key, instance_id)
2929
if score == false then
3030
-- Instance doesn't hold the semaphore
3131
local current_count = redis.call('ZCARD', semaphore_key)
32-
return {0, 'not_held', current_count, expired_count}
32+
return {255, 'not_held', current_count, expired_count}
3333
end
3434

3535
-- Step 3: Remove the semaphore entry and holder key

0 commit comments

Comments
 (0)