From 2f78bd592ad7822597b81de2b797e8f32b177220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Bj=C3=B6rklund?= Date: Wed, 11 Dec 2019 00:51:05 +0100 Subject: [PATCH] [issue-5] def acquire no longer takes key as argument (#6) --- aioredis_lock/locks.py | 7 +++---- setup.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/aioredis_lock/locks.py b/aioredis_lock/locks.py index a76709d..9351006 100644 --- a/aioredis_lock/locks.py +++ b/aioredis_lock/locks.py @@ -69,7 +69,7 @@ async def renew_script(self) -> str: return self._renew_script async def __aenter__(self): - if await self.acquire(self.key, self.timeout, self.wait_timeout): + if await self.acquire(self.timeout, self.wait_timeout): return self raise LockTimeoutError("Unable to acquire lock within timeout") @@ -83,11 +83,10 @@ async def is_owner(self) -> bool: await self.pool_or_conn.get(self.key) ) == self._token.encode() # pylint: disable=no-member - async def acquire(self, key, timeout=30, wait_timeout=30) -> bool: + async def acquire(self, timeout=30, wait_timeout=30) -> bool: """ Attempt to acquire the lock - :param key: Lock key :param timeout: Number of seconds until the lock should timeout. It can be extended via extend :param wait_timeout: How long to wait before aborting the lock request @@ -97,7 +96,7 @@ async def acquire(self, key, timeout=30, wait_timeout=30) -> bool: while True: if await self._script_exec( (await self.acquire_script()), - keys=[key], + keys=[self.key], args=[self._token, timeout * 1000], ): return True diff --git a/setup.py b/setup.py index f37c9d3..daaf3c5 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import find_packages, setup -__version__ = "0.0.3" +__version__ = "0.1.0" with open(Path(__file__).parent / "README.md") as f: