Initial commit

This commit is contained in:
LZH-YS1998
2026-07-01 17:56:31 +08:00
commit d78931979d
731 changed files with 311088 additions and 0 deletions
@@ -0,0 +1,27 @@
"""Periodic reconcile loop for cross-process board consistency."""
from __future__ import annotations
import asyncio
from collections.abc import Awaitable, Callable
class ReconcileLoop:
"""Run a callback periodically until stopped."""
def __init__(self, interval_seconds: float, callback: Callable[[], Awaitable[None]]) -> None:
self.interval_seconds = max(0.5, float(interval_seconds))
self._callback = callback
self._stop_event = asyncio.Event()
async def run(self) -> None:
while not self._stop_event.is_set():
await self._callback()
try:
await asyncio.wait_for(self._stop_event.wait(), timeout=self.interval_seconds)
except asyncio.TimeoutError:
continue
def stop(self) -> None:
self._stop_event.set()