Skip to content

Commit 132efcf

Browse files
wmorrellcarltongibson
authored andcommitted
Check aioredis version for deprecated parameter
Starting with aioredis 1.3.1, the loop parameter is deprecated when calling create_redis. See aio-libs-abandoned/aioredis-py#666 and #179. When running Python 3.8+ and aioredis 1.3.1+, calls should omit the loop parameter. Otherwise, continue to include the parameter for the older versions that expect it.
1 parent d96aa34 commit 132efcf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

channels_redis/core.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import logging
88
import random
99
import string
10+
import sys
1011
import time
1112
import types
1213

@@ -18,6 +19,8 @@
1819

1920
logger = logging.getLogger(__name__)
2021

22+
AIOREDIS_VERSION = tuple(map(int, aioredis.__version__.split(".")))
23+
2124

2225
def _wrap_close(loop, pool):
2326
"""
@@ -70,7 +73,11 @@ async def pop(self, loop=None):
7073
"""
7174
conns, loop = self._ensure_loop(loop)
7275
if not conns:
73-
conns.append(await aioredis.create_redis(**self.host, loop=loop))
76+
if sys.version_info >= (3, 8, 0) and AIOREDIS_VERSION >= (1, 3, 1):
77+
conn = await aioredis.create_redis(**self.host)
78+
else:
79+
conn = await aioredis.create_redis(**self.host, loop=loop)
80+
conns.append(conn)
7481
conn = conns.pop()
7582
if conn.closed:
7683
conn = await self.pop(loop=loop)

0 commit comments

Comments
 (0)