import asyncio import logging from app.db.base import SessionLocal from app.fitness.reminders import check_reminders logger = logging.getLogger(__name__) WATCH_INTERVAL_SEC = 60 async def fitness_watcher_loop() -> None: while True: try: await asyncio.sleep(WATCH_INTERVAL_SEC) await _tick() except asyncio.CancelledError: raise except Exception: logger.exception("Fitness watcher error") async def _tick() -> None: db = SessionLocal() try: check_reminders(db) finally: db.close()