You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
609 B
Python
19 lines
609 B
Python
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)
|