diff options
Diffstat (limited to 'redis/asyncio/lock.py')
-rw-r--r-- | redis/asyncio/lock.py | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/redis/asyncio/lock.py b/redis/asyncio/lock.py index fc7df37..8ede59b 100644 --- a/redis/asyncio/lock.py +++ b/redis/asyncio/lock.py @@ -1,5 +1,4 @@ import asyncio -import sys import threading import uuid from types import SimpleNamespace @@ -186,11 +185,6 @@ class Lock: object with the default encoding. If a token isn't specified, a UUID will be generated. """ - if sys.version_info[0:2] != (3, 6): - loop = asyncio.get_running_loop() - else: - loop = asyncio.get_event_loop() - sleep = self.sleep if token is None: token = uuid.uuid1().hex.encode() @@ -203,14 +197,14 @@ class Lock: blocking_timeout = self.blocking_timeout stop_trying_at = None if blocking_timeout is not None: - stop_trying_at = loop.time() + blocking_timeout + stop_trying_at = asyncio.get_event_loop().time() + blocking_timeout while True: if await self.do_acquire(token): self.local.token = token return True if not blocking: return False - next_try_at = loop.time() + sleep + next_try_at = asyncio.get_event_loop().time() + sleep if stop_trying_at is not None and next_try_at > stop_trying_at: return False await asyncio.sleep(sleep) |