fix: non-blocking initial device check to prevent startup hang

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Christian Mueller 2026-04-23 23:49:13 +02:00
parent 3329a5dc5a
commit 327edf4f16

5
app.py
View File

@ -39,12 +39,11 @@ async def lifespan(application: FastAPI):
interval = int(database.get_setting("poll_interval", "15"))
bg_scheduler.add_job(scheduler.poll_status, "interval", seconds=interval, id="poll")
bg_scheduler.add_job(scheduler.check_devices, "interval", seconds=240, id="device_check")
# Initial device check nach 5 Sekunden (nicht blockierend)
bg_scheduler.add_job(scheduler.check_devices, "date", id="device_check_init")
bg_scheduler.start()
logger.info("Polling gestartet (Intervall: %ds)", interval)
# Initial device check
scheduler.check_devices()
yield
bg_scheduler.shutdown()