from __future__ import annotations import asyncio, socket, logging from . import config logger = logging.getLogger("PTZTracker") async def heartbeat_pinger() -> None: addr = (config.HEARTBEAT_HOST, config.HEARTBEAT_PORT) with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: try: s.setblocking(False) except Exception: pass while True: try: s.sendto(b"hb", addr) except Exception as e: logger.debug("heartbeat send failed: %s", e) await asyncio.sleep(config.HEARTBEAT_INTERVAL)