From 3f9b65cc3ec63870750b3f16411a5cebec1e9c12 Mon Sep 17 00:00:00 2001 From: Konrads Klints Date: Sun, 11 Dec 2022 12:33:33 +0800 Subject: [PATCH] Do not pass loop if Python >=3.10 --- aredis/connection.py | 15 +++++++++++---- aredis/utils.py | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/aredis/connection.py b/aredis/connection.py index 6dc79050..5c8e1054 100755 --- a/aredis/connection.py +++ b/aredis/connection.py @@ -17,7 +17,7 @@ InvalidResponse, AskError, MovedError, TryAgainError, ClusterDownError, ClusterCrossSlotError) -from aredis.utils import b, nativestr, LOOP_DEPRECATED +from aredis.utils import b, nativestr, LOOP_DEPRECATED, LOOP_DEPRECATED_OPEN_CONNECTION try: import hiredis @@ -593,11 +593,18 @@ def __init__(self, host='127.0.0.1', port=6379, password=None, self.socket_keepalive_options = socket_keepalive_options or {} async def _connect(self): - reader, writer = await exec_with_timeout( - asyncio.open_connection(host=self.host, + if LOOP_DEPRECATED_OPEN_CONNECTION: + coro=asyncio.open_connection(host=self.host, + port=self.port, + ssl=self.ssl_context) + else: + coro=asyncio.open_connection(host=self.host, port=self.port, ssl=self.ssl_context, - loop=self.loop), + loop=self.loop) + + reader, writer = await exec_with_timeout(coro + , self._connect_timeout, loop=self.loop ) diff --git a/aredis/utils.py b/aredis/utils.py index f83fbbf8..c2481bc5 100644 --- a/aredis/utils.py +++ b/aredis/utils.py @@ -12,6 +12,7 @@ pass LOOP_DEPRECATED = sys.version_info >= (3, 8) +LOOP_DEPRECATED_OPEN_CONNECTION=sys.version_info >= (3, 10) def b(x):