From d1de6566dc7afc50a8d1eb3eca3b0e69bd932aef Mon Sep 17 00:00:00 2001 From: Ali-Akber Saifee Date: Wed, 5 Jan 2022 13:19:12 -0800 Subject: [PATCH] Don't open connnection with loop for python 3.10 Originally posted in https://github.com/NoneGG/aredis/pull/208 --- coredis/connection.py | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/coredis/connection.py b/coredis/connection.py index 2a2e83ca..388e9d23 100755 --- a/coredis/connection.py +++ b/coredis/connection.py @@ -593,11 +593,21 @@ def __init__(self, host='127.0.0.1', port=6379, password=None, self.socket_keepalive_options = socket_keepalive_options or {} async def _connect(self): + if LOOP_DEPRECATED: + connection = asyncio.open_connection( + host=self.host, + port=self.port, + ssl=self.ssl_context + ) + else: + connection = asyncio.open_connection( + host=self.host, + port=self.port, + ssl=self.ssl_context, + loop=self.loop + ) reader, writer = await exec_with_timeout( - asyncio.open_connection(host=self.host, - port=self.port, - ssl=self.ssl_context, - loop=self.loop), + connection, self._connect_timeout, loop=self.loop ) @@ -642,10 +652,19 @@ def __init__(self, path='', password=None, } async def _connect(self): + if LOOP_DEPRECATED: + connection = asyncio.open_unix_connection( + path=self.path, + ssl=self.ssl_context + ) + else: + connection = asyncio.open_unix_connection( + path=self.path, + ssl=self.ssl_context, + loop=self.loop + ) reader, writer = await exec_with_timeout( - asyncio.open_unix_connection(path=self.path, - ssl=self.ssl_context, - loop=self.loop), + connection, self._connect_timeout, loop=self.loop )