excel-planner/dashboard/refresh_debouncer.py
juan.pelaez 27d759ace8 Agregar integracion Excel-Planner con tablero RTC Sapian.
Puente Power Automate, servidor local del tablero HTML v7 y exportacion a Excel/TSV para monitoreo de proyectos en Microsoft Planner.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-10 13:44:38 -05:00

21 lines
678 B
Python

"""Agrupa varios webhooks seguidos en un solo refresco de datos."""
from __future__ import annotations
import threading
from collections.abc import Callable
class RefreshDebouncer:
def __init__(self, delay_seconds: float) -> None:
self.delay_seconds = delay_seconds
self._lock = threading.Lock()
self._timer: threading.Timer | None = None
def schedule(self, callback: Callable[[], None]) -> None:
with self._lock:
if self._timer is not None:
self._timer.cancel()
self._timer = threading.Timer(self.delay_seconds, callback)
self._timer.daemon = True
self._timer.start()