update_manager: fix potential race condition with auto_refresh

Wait until update manager init is complete before attempting starting the auto refresh periodic callback.  This prevents an auto refresh from blocking init if Moonraker is started during the auto refresh window.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2021-07-15 06:20:12 -04:00
parent 7f740ccb5a
commit 0d1431395e
1 changed files with 2 additions and 1 deletions

View File

@ -142,7 +142,6 @@ class UpdateManager:
self.refresh_cb = PeriodicCallback(
self._handle_auto_refresh, # type: ignore
UPDATE_REFRESH_INTERVAL_MS)
self.refresh_cb.start()
self.server.register_endpoint(
"/machine/update/moonraker", ["POST"],
@ -187,6 +186,8 @@ class UpdateManager:
ret = updater.refresh()
await ret
self.initialized_lock.set()
if self.refresh_cb is not None:
self.refresh_cb.start()
async def _set_klipper_repo(self) -> None:
if self.klippy_identified_evt is not None: