修复中控轮询连锁唤醒导致 CPU 居高不下:轮询加最小间隔并取消 board 每轮强制刷新看板。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-25 12:35:41 +08:00
parent 75f50fe083
commit b63f6f0962
8 changed files with 131 additions and 35 deletions
+8 -8
View File
@@ -5,10 +5,12 @@ from __future__ import annotations
import asyncio
import json
import os
import time
from collections.abc import AsyncIterator, Awaitable, Callable
from typing import Any
from hub_dashboard import DASHBOARD_POLL_INTERVAL_SEC
from lib.hub.hub_poll_wait_lib import wait_poll_interval
HUB_DASHBOARD_SSE_HEARTBEAT_SEC = float(os.getenv("HUB_DASHBOARD_SSE_HEARTBEAT_SEC", "25"))
@@ -81,18 +83,16 @@ class DashboardStore:
async def _loop(self) -> None:
assert self._build_fn is not None
while not self._stop.is_set():
started = time.monotonic()
await self._aggregate_once(self._build_fn)
if self._stop.is_set():
break
self._refresh.clear()
sleep_task = asyncio.create_task(asyncio.sleep(DASHBOARD_POLL_INTERVAL_SEC))
refresh_task = asyncio.create_task(self._refresh.wait())
done, pending = await asyncio.wait(
{sleep_task, refresh_task},
return_when=asyncio.FIRST_COMPLETED,
await wait_poll_interval(
refresh=self._refresh,
stop=self._stop,
interval_sec=DASHBOARD_POLL_INTERVAL_SEC,
started_at=started,
)
for t in pending:
t.cancel()
async def _aggregate_once(self, build_fn: BuildFn) -> None:
async with self._lock: