INNER CODE UNIT · Python
poll_and_reload
yihong1120/Construction-Hazard-Detection · main.py:281
async def poll_and_reload(self) -> None:
"""Run the low-frequency health fallback and stream-expiry timer.
PostgreSQL ``LISTEN`` drives ordinary changes. The fallback recovers
from a lost listener and wakes at the nearest configured expiry even
when no database row changes.
"""
while True:
try:
await self.reload_configurations()
except TimeoutError as e:
self.logger.exception(f"[poll] Reload timeout: {e}")
await self._reset_db_pool()
await self._ensure_config_listener()
except Exception as e:
self.logger.exception(f"[poll] Reload error: {e}")
await asyncio.sleep(self._next_configuration_reload_delay())