Skip to content

Commit 90b2f94

Browse files
authored
follow-up to #1066: update redis to 5.0.0 which includes full fix for connection leak in from_url(), (#1081)
simplifies previous workaround addressed in 5.0.0
1 parent 768d118 commit 90b2f94

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

backend/btrixcloud/k8sapi.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
from kubernetes_asyncio.utils import create_from_dict
1414
from kubernetes_asyncio.client.exceptions import ApiException
1515

16-
from redis.asyncio import Redis
17-
from redis.asyncio.connection import ConnectionPool
16+
from redis import asyncio as aioredis
1817

1918
from fastapi.templating import Jinja2Templates
2019
from .utils import get_templates_dir, dt_now, to_k8s_date
@@ -67,14 +66,9 @@ def get_redis_url(self, crawl_id):
6766

6867
async def get_redis_client(self, redis_url):
6968
"""return redis client with correct params for one-time use"""
70-
# manual settings until redis 5.0.0 is released
71-
pool = ConnectionPool.from_url(redis_url, decode_responses=True)
72-
redis = Redis(
73-
connection_pool=pool,
74-
decode_responses=True,
69+
return aioredis.from_url(
70+
redis_url, decode_responses=True, auto_close_connection_pool=True
7571
)
76-
redis.auto_close_connection_pool = True
77-
return redis
7872

7973
# pylint: disable=too-many-arguments
8074
async def new_crawl_job(

backend/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ loguru
55
aiofiles
66
kubernetes-asyncio==22.6.5
77
aiobotocore
8-
redis>=5.0.0rc2
8+
redis>=5.0.0
99
pyyaml
1010
jinja2
1111
humanize

0 commit comments

Comments
 (0)