diff --git a/channels_redis/core.py b/channels_redis/core.py index f4ff59bb..d7100a3c 100644 --- a/channels_redis/core.py +++ b/channels_redis/core.py @@ -7,6 +7,7 @@ import logging import random import string +import sys import time import types @@ -18,6 +19,8 @@ logger = logging.getLogger(__name__) +AIOREDIS_VERSION = tuple(map(int, aioredis.__version__.split("."))) + def _wrap_close(loop, pool): """ @@ -70,7 +73,11 @@ async def pop(self, loop=None): """ conns, loop = self._ensure_loop(loop) if not conns: - conns.append(await aioredis.create_redis(**self.host, loop=loop)) + if sys.version_info >= (3, 8, 0) and AIOREDIS_VERSION >= (1, 3, 1): + conn = await aioredis.create_redis(**self.host) + else: + conn = await aioredis.create_redis(**self.host, loop=loop) + conns.append(conn) conn = conns.pop() if conn.closed: conn = await self.pop(loop=loop)