Skip to content

Commit

Permalink
create redis as for aioredis 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
afeena committed Jan 15, 2022
1 parent 20dabcb commit 478f2a7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tanner/redis_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ async def get_redis_client(poolsize=None):
redis_client = None
try:
host = TannerConfig.get("REDIS", "host")
port = TannerConfig.get("REDIS", "port")
if poolsize is None:
poolsize = TannerConfig.get("REDIS", "poolsize")
timeout = TannerConfig.get("REDIS", "timeout")
redis_client = await asyncio.wait_for(
aioredis.create_redis_pool((host, int(port)), maxsize=int(poolsize)), timeout=int(timeout)
redis_client = aioredis.from_url(
f"redis://{username}:{password}@{host}:{port}",
encoding="utf-8",
decode_responses=True,
max_connections=poolsize
)
except asyncio.TimeoutError as timeout_error:
LOGGER.exception("Problem with redis connection. Please, check your redis server. %s", timeout_error)
Expand Down

0 comments on commit 478f2a7

Please sign in to comment.