import threading class LiveHub: def __init__(self) -> None: self._condition = threading.Condition() self.revision = 0 def touch(self) -> None: with self._condition: self.revision += 1 self._condition.notify_all() def wait(self, seen: int, timeout: float = 20) -> int: with self._condition: if self.revision == seen: self._condition.wait(timeout) return self.revision live = LiveHub()