Skip to content

Commit

Permalink
ISSUE-96: after using sub-class of Lock, TypeErr raise
Browse files Browse the repository at this point in the history
  • Loading branch information
gshmu authored Jun 14, 2024
1 parent e5f596f commit 7ef84ea
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/redis_lock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,11 @@ def __init__(self, redis_client, name, expire=None, id=None, auto_renewal=False,

@classmethod
def register_scripts(cls, redis_client):
global reset_all_script
if reset_all_script is None:
if cls.reset_all_script is None:
cls.unlock_script = redis_client.register_script(UNLOCK_SCRIPT)
cls.extend_script = redis_client.register_script(EXTEND_SCRIPT)
cls.reset_script = redis_client.register_script(RESET_SCRIPT)
cls.reset_all_script = redis_client.register_script(RESET_ALL_SCRIPT)
reset_all_script = redis_client.register_script(RESET_ALL_SCRIPT)

@property
def _held(self):
Expand Down Expand Up @@ -363,9 +361,6 @@ def locked(self):
return self._client.exists(self._name) == 1


reset_all_script = None


def reset_all(redis_client):
"""
Forcibly deletes all locks if its remains (like a crash reason). Use this with care.
Expand All @@ -375,4 +370,4 @@ def reset_all(redis_client):
"""
Lock.register_scripts(redis_client)

reset_all_script(client=redis_client) # noqa
Lock.reset_all_script(client=redis_client) # noqa

0 comments on commit 7ef84ea

Please sign in to comment.