Skip to content

Commit

Permalink
avoid warnings in redis cleanup
Browse files Browse the repository at this point in the history
- redis.close deprecated in favor of redis.aclose
- make sure to close external redis proxy client to avoid warnings during teardown
  • Loading branch information
minrk committed Aug 21, 2024
1 parent 0d05f51 commit 98bc9cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion jupyterhub_traefik_proxy/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ async def _cleanup(self):
f = super()._cleanup()
if f is not None:
await f
await self.redis.close()
if hasattr(self.redis, 'aclose'):
aclose = self.redis.aclose
else:
# redis < 5.0.1
aclose = self.redis.close
await aclose()

def _setup_traefik_static_config(self):
self.log.debug("Setting up the redis provider in the traefik static config")
Expand Down
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ async def external_redis_proxy(launch_traefik_redis, proxy_args):
)
await proxy._start_future
yield proxy
await proxy._cleanup()


@pytest.fixture
Expand Down Expand Up @@ -801,6 +802,7 @@ async def _wait_for_redis():
from redis.asyncio import Redis

async def _check_redis():
r = None
try:
r = Redis(
port=Config.redis_port,
Expand All @@ -811,6 +813,10 @@ async def _check_redis():
except redis.exceptions.ConnectionError as e:
print(e)
return False
finally:
if r is not None:
await r.aclose()

return True

await exponential_backoff(
Expand Down

0 comments on commit 98bc9cc

Please sign in to comment.