INNER CODE UNIT · Python
__init__
yihong1120/Construction-Hazard-Detection · main.py:43
def __init__(self, poll_interval: int = 300) -> None:
"""Initialise the application.
Args:
poll_interval (int): Maximum seconds between fallback database
refreshes when PostgreSQL notifications are unavailable.
"""
self.poll_interval = max(1, poll_interval)
self.logger = LoggerConfig().get_logger()
# Stable stream identity → process info. RTSP URLs are sources, not
# identifiers: multiple configured cameras may deliberately share one.
self.running_processes: dict[str, dict] = {}
self.lock = asyncio.Lock() # Prevent overlapping reloads
self.db_pool: Pool | None = None # PostgreSQL async connection pool
self._config_listener_connection: Any | None = None
self._config_reload_task: asyncio.Task[None] | None = None
self._config_reload_requested = False
self._last_config_summary: tuple[int, int, int] | None = None