MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _benchmark_refresh_loop

Function _benchmark_refresh_loop

uncommon_route/proxy.py:2987–3005  ·  view source on GitHub ↗

Refresh external benchmark priors off the request path. Providers still enforce their own TTLs, so this loop is cheap when cached data is fresh and avoids blocking live routing on network calls.

()

Source from the content-addressed store, hash-verified

2985 logger.warning("Rediscovery failed: %s", exc)
2986
2987 async def _benchmark_refresh_loop() -> None:
2988 """Refresh external benchmark priors off the request path.
2989
2990 Providers still enforce their own TTLs, so this loop is cheap when
2991 cached data is fresh and avoids blocking live routing on network calls.
2992 """
2993 import asyncio
2994 interval = float(os.environ.get("UNCOMMON_ROUTE_BENCHMARK_REFRESH_INTERVAL", "3600"))
2995 if interval <= 0:
2996 return
2997 while True:
2998 await asyncio.sleep(interval)
2999 try:
3000 from uncommon_route.benchmark import get_benchmark_cache
3001 count = await get_benchmark_cache().refresh()
3002 if count > 0:
3003 logger.info("Benchmark refresh: %d models updated", count)
3004 except Exception as exc: # noqa: BLE001
3005 logger.warning("Benchmark refresh failed: %s", exc)
3006
3007 def _selector_state(
3008 *,

Callers 1

_lifespanFunction · 0.85

Calls 4

get_benchmark_cacheFunction · 0.90
refreshMethod · 0.80
infoMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected