From 6c3f671636fe6e3ec30518c6e5ad8bb9584b120b Mon Sep 17 00:00:00 2001 From: Benjamin McCormick Date: Fri, 23 Jan 2026 17:57:58 -0500 Subject: [PATCH] fix: clean Redis URL by removing query parameters in cache client and update flush mode logging in benchmark runner --- src/cache/client.py | 8 ++++++-- tests/bench/runner_common.py | 9 +++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/cache/client.py b/src/cache/client.py index 0381dd4a..0b8480ca 100644 --- a/src/cache/client.py +++ b/src/cache/client.py @@ -3,7 +3,9 @@ from __future__ import annotations import asyncio import logging from typing import cast +from urllib.parse import urlparse, urlunparse +import redis.asyncio as aioredis import sentry_sdk from cashews import cache from cashews.picklers import PicklerType @@ -126,9 +128,11 @@ async def is_deriver_flush_enabled() -> bool: if not is_cache_enabled(): return False try: - import redis.asyncio as aioredis + # Strip query parameters - redis-py doesn't support custom params like ?suppress=true + parsed = urlparse(settings.CACHE.URL) + clean_url = urlunparse(parsed._replace(query="")) - redis_client = aioredis.from_url(settings.CACHE.URL) # pyright: ignore[reportUnknownMemberType] + redis_client = aioredis.from_url(clean_url) # pyright: ignore[reportUnknownMemberType] try: result = await redis_client.get(DERIVER_FLUSH_KEY) return result == b"1" diff --git a/tests/bench/runner_common.py b/tests/bench/runner_common.py index dea8e544..0cfcc79b 100644 --- a/tests/bench/runner_common.py +++ b/tests/bench/runner_common.py @@ -623,13 +623,14 @@ class BaseRunner(ABC, Generic[ResultT]): async def _flush_deriver_queue(self) -> None: """Enable deriver flush mode to bypass batch token threshold.""" - if self.config.base_url: - print("Skipping flush mode (remote instance)") + default_redis_url = "redis://localhost:6379/0" + if self.config.base_url and self.config.redis_url == default_redis_url: + print("Skipping flush mode (remote instance, no --redis-url provided)") return redis_client: Redis = aioredis.from_url(self.config.redis_url) # pyright: ignore[reportUnknownMemberType] try: - await redis_client.set("honcho:deriver:flush_mode", "1", ex=60) - print("Enabled deriver flush mode") + await redis_client.set("honcho:deriver:flush_mode", "1", ex=3600) + print(f"Enabled deriver flush mode via {self.config.redis_url}") finally: await redis_client.aclose()