diff options
author | dvora-h <67596500+dvora-h@users.noreply.github.com> | 2022-07-27 16:18:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-27 16:18:41 +0300 |
commit | 607a59ad6ff0cabc7b0af7480f42043aebc2a33b (patch) | |
tree | 9aed66dc63dabb925c08203c2dc82b057305e85a /redis/asyncio/lock.py | |
parent | f665bd306dc843cec3e8fa01d6f4061385d1812e (diff) | |
download | redis-py-607a59ad6ff0cabc7b0af7480f42043aebc2a33b.tar.gz |
Drop python 3.6 support (#2306)
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) |