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 | |
parent | f665bd306dc843cec3e8fa01d6f4061385d1812e (diff) | |
download | redis-py-607a59ad6ff0cabc7b0af7480f42043aebc2a33b.tar.gz |
Drop python 3.6 support (#2306)
Diffstat (limited to 'redis/asyncio')
-rw-r--r-- | redis/asyncio/cluster.py | 6 | ||||
-rw-r--r-- | redis/asyncio/connection.py | 25 | ||||
-rw-r--r-- | redis/asyncio/lock.py | 10 |
3 files changed, 12 insertions, 29 deletions
diff --git a/redis/asyncio/cluster.py b/redis/asyncio/cluster.py index df0c17d..1a33563 100644 --- a/redis/asyncio/cluster.py +++ b/redis/asyncio/cluster.py @@ -377,8 +377,7 @@ class RedisCluster(AbstractRedis, AbstractRedisCluster, AsyncRedisClusterCommand warnings.warn(f"{self._DEL_MESSAGE} {self!r}", ResourceWarning, source=self) try: context = {"client": self, "message": self._DEL_MESSAGE} - # TODO: Change to get_running_loop() when dropping support for py3.6 - asyncio.get_event_loop().call_exception_handler(context) + asyncio.get_running_loop().call_exception_handler(context) except RuntimeError: ... @@ -834,8 +833,7 @@ class ClusterNode: ) try: context = {"client": self, "message": self._DEL_MESSAGE} - # TODO: Change to get_running_loop() when dropping support for py3.6 - asyncio.get_event_loop().call_exception_handler(context) + asyncio.get_running_loop().call_exception_handler(context) except RuntimeError: ... break diff --git a/redis/asyncio/connection.py b/redis/asyncio/connection.py index 4c75d2f..6823dcb 100644 --- a/redis/asyncio/connection.py +++ b/redis/asyncio/connection.py @@ -7,7 +7,6 @@ import io import os import socket import ssl -import sys import threading import weakref from itertools import chain @@ -864,12 +863,10 @@ class Connection: async def check_health(self): """Check the health of the connection with a PING/PONG""" - if sys.version_info[0:2] == (3, 6): - func = asyncio.get_event_loop - else: - func = asyncio.get_running_loop - - if self.health_check_interval and func().time() > self.next_health_check: + if ( + self.health_check_interval + and asyncio.get_running_loop().time() > self.next_health_check + ): await self.retry.call_with_retry(self._send_ping, self._ping_failed) async def _send_packed_command(self, command: Iterable[bytes]) -> None: @@ -957,11 +954,8 @@ class Connection: raise if self.health_check_interval: - if sys.version_info[0:2] == (3, 6): - func = asyncio.get_event_loop - else: - func = asyncio.get_running_loop - self.next_health_check = func().time() + self.health_check_interval + next_time = asyncio.get_running_loop().time() + self.health_check_interval + self.next_health_check = next_time if isinstance(response, ResponseError): raise response from None @@ -992,11 +986,8 @@ class Connection: raise if self.health_check_interval: - if sys.version_info[0:2] == (3, 6): - func = asyncio.get_event_loop - else: - func = asyncio.get_running_loop - self.next_health_check = func().time() + self.health_check_interval + next_time = asyncio.get_running_loop().time() + self.health_check_interval + self.next_health_check = next_time if isinstance(response, ResponseError): raise response from None 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) |