From 667291a2dcaeae21e27eeb6376085e69caa4e45a Mon Sep 17 00:00:00 2001 From: Fringg Date: Thu, 5 Mar 2026 06:00:30 +0300 Subject: [PATCH] fix: redis cache uses sync client due to import shadowing import redis.exceptions overwrites the redis name binding from import redis.asyncio as redis, causing from_url() to create a sync client. ping() then returns bool instead of coroutine. Fix: from redis.exceptions import NoScriptError --- app/utils/cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/utils/cache.py b/app/utils/cache.py index 7f2b658d..712d5dc3 100644 --- a/app/utils/cache.py +++ b/app/utils/cache.py @@ -4,8 +4,8 @@ from datetime import timedelta from typing import Any import redis.asyncio as redis -import redis.exceptions import structlog +from redis.exceptions import NoScriptError from app.config import settings @@ -383,7 +383,7 @@ return c key, window, ) - except redis.exceptions.NoScriptError: + except NoScriptError: # SHA evicted from Redis script cache — reload and retry RateLimitCache._rate_limit_sha = await cache.redis_client.script_load( RateLimitCache._RATE_LIMIT_SCRIPT,