diff --git a/router/router.py b/router/router.py index efb8760..6fd9289 100644 --- a/router/router.py +++ b/router/router.py @@ -54,7 +54,7 @@ def check_rate_limit(api_key, tier): return True, 999, 60 limit = RATE_LIMIT_RPM.get(tier, 30) key = f"ratelimit:{api_key}" - current = int(r.get(key) or 0) + current = int(get_redis().get(key) or 0) if current >= limit: ttl = r.ttl(key) retry = max(ttl, 1) if ttl and ttl > 0 else 60 @@ -105,9 +105,9 @@ def counter_audit_loop(): slots = resp.json() all_idle = all(not s.get("is_processing", False) for s in slots) if all_idle: - current = int(r.get("active:" + model) or 0) + current = int(get_redis().get("active:" + model) or 0) if current > 0: - rd.set("active:" + model, 0) + get_redis().set("active:" + model, 0) log.info("AUDIT: Reset stuck counter for %s (was %d)", model, current) except Exception: pass @@ -131,7 +131,7 @@ def gpu_decr(model): if rd: v = rd.decr("active:" + model) if v and int(v) < 0: - rd.set("active:" + model, 0) # never go negative + get_redis().set("active:" + model, 0) # never go negative def check_gpu_health(model, sidecar_timeout=5, gpu_timeout=3): url = GPU_SIDECARS.get(model) if not url: return {"status": "unknown"}