From 0d1431395eaaf7d13cf2d03b0d24a1dc670083b7 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Thu, 15 Jul 2021 06:20:12 -0400 Subject: [PATCH] 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 --- moonraker/components/update_manager/update_manager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/moonraker/components/update_manager/update_manager.py b/moonraker/components/update_manager/update_manager.py index 4a918da..a30f796 100644 --- a/moonraker/components/update_manager/update_manager.py +++ b/moonraker/components/update_manager/update_manager.py @@ -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: