Skip to content

Commit abe1f43

Browse files
authored
Merge branch 'master' into dependabot/pip/pywin32-301
2 parents 062edb5 + 4cf39e3 commit abe1f43

File tree

5 files changed

+62
-12
lines changed

5 files changed

+62
-12
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
release:
10+
name: Release to PyPi
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Install Poetry
17+
run: pipx install poetry
18+
19+
- name: Build
20+
run: poetry build
21+
22+
- name: Publish
23+
env:
24+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.POETRY_PYPI_TOKEN_PYPI }}
25+
run: |
26+
poetry config pypi-token.pypi "$POETRY_PYPI_TOKEN_PYPI"
27+
poetry publish

CHANGELOG.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@ CHANGELOG
44
Development Version
55
+++++++++++++++++++
66

7+
0.4.0
8+
*****
9+
10+
* [BREAKING] Drop support for `python<3.7`
11+
12+
* [FEAT] Add `KubernetesLock` backend
13+
* [FEAT] Add `FileLock` backend
14+
* [FEAT] Install backend specific dependencies with extras #59_
15+
* [FEAT] Add `.renew()` method to all backends #61_
16+
17+
* [BUGFIX] Use `ARGV` in Redis Lua scripts to add RedisCluster compatibility #31_
18+
* [BUGFIX] `redis>=2.10.6` client won't work with `sherlock 0.3.1` #32_
19+
* [BUGFIX] `timeout=0` doesn't work as expected with `RedisLock` #60_
20+
21+
.. _#31: https://github.com/vaidik/sherlock/issues/31
22+
.. _#32: https://github.com/vaidik/sherlock/issues/32
23+
.. _#59: https://github.com/py-sherlock/sherlock/pull/59
24+
.. _#60: https://github.com/py-sherlock/sherlock/pull/60
25+
.. _#61: https://github.com/py-sherlock/sherlock/pull/61
26+
727
0.3.2
828
*****
929

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[tool.poetry]
44
name = "sherlock"
5-
version = "0.4.0a0"
5+
version = "0.4.0"
66
description = "Distributed inter-process locks with a choice of backend"
77
license = "MIT"
88
authors = [

sherlock/lock.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,16 +412,16 @@ class RedisLock(BaseLock):
412412
"""
413413

414414
_acquire_script = """
415-
local result = redis.call('SETNX', KEYS[1], KEYS[2])
416-
if result == 1 and KEYS[3] ~= -1 then
417-
redis.call('EXPIRE', KEYS[1], KEYS[3])
415+
local result = redis.call('SETNX', KEYS[1], ARGV[1])
416+
if result == 1 and ARGV[2] ~= -1 then
417+
redis.call('EXPIRE', KEYS[1], ARGV[2])
418418
end
419419
return result
420420
"""
421421

422422
_release_script = """
423423
local result = 0
424-
if redis.call('GET', KEYS[1]) == KEYS[2] then
424+
if redis.call('GET', KEYS[1]) == ARGV[1] then
425425
redis.call('DEL', KEYS[1])
426426
result = 1
427427
end
@@ -430,9 +430,9 @@ class RedisLock(BaseLock):
430430

431431
_renew_script = """
432432
local result = 0
433-
if redis.call('GET', KEYS[1]) == KEYS[2] then
434-
if KEYS[3] ~= -1 then
435-
redis.call('EXPIRE', KEYS[1], KEYS[3])
433+
if redis.call('GET', KEYS[1]) == ARGV[1] then
434+
if ARGV[2] ~= -1 then
435+
redis.call('EXPIRE', KEYS[1], ARGV[2])
436436
else
437437
redis.call('PERSIST', KEYS[1])
438438
end
@@ -485,7 +485,7 @@ def _acquire(self):
485485
expire = -1
486486
else:
487487
expire = self.expire
488-
if self._acquire_func(keys=[self._key_name, owner, expire]) != 1:
488+
if self._acquire_func(keys=[self._key_name], args=[owner, expire]) != 1:
489489
return False
490490
self._owner = owner
491491
return True
@@ -494,7 +494,7 @@ def _release(self):
494494
if self._owner is None:
495495
raise LockException("Lock was not set by this process.")
496496

497-
if self._release_func(keys=[self._key_name, self._owner]) != 1:
497+
if self._release_func(keys=[self._key_name], args=[self._owner]) != 1:
498498
raise LockException(
499499
"Lock could not be released because it was "
500500
"not acquired by this instance."
@@ -506,7 +506,10 @@ def _renew(self) -> bool:
506506
if self._owner is None:
507507
raise LockException("Lock was not set by this process.")
508508

509-
if self._release_func(keys=[self._key_name, self._owner, self.expire]) != 1:
509+
if (
510+
self._release_func(keys=[self._key_name], args=[self._owner, self.expire])
511+
!= 1
512+
):
510513
return False
511514
return True
512515

0 commit comments

Comments
 (0)