From 48621da6aab2f648a928a9a46476661f3e4ad730 Mon Sep 17 00:00:00 2001 From: Arksine Date: Wed, 17 Mar 2021 17:35:34 -0400 Subject: [PATCH] update_manager: apply the command lock to initialization This makes sure that the Klipper and Moonraker git repos are not initialized simultaneously. Signed-off-by: Eric Callahan --- moonraker/plugins/update_manager.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/moonraker/plugins/update_manager.py b/moonraker/plugins/update_manager.py index 548003c..a46bfa0 100644 --- a/moonraker/plugins/update_manager.py +++ b/moonraker/plugins/update_manager.py @@ -114,16 +114,17 @@ class UpdateManager: self._initalize_updaters, list(self.updaters.values())) async def _initalize_updaters(self, initial_updaters): - self.is_refreshing = True - await self.cmd_helper.init_api_rate_limit() - for updater in initial_updaters: - if isinstance(updater, PackageUpdater): - ret = updater.refresh(False) - else: - ret = updater.refresh() - if asyncio.iscoroutine(ret): - await ret - self.is_refreshing = False + async with self.cmd_request_lock: + self.is_refreshing = True + await self.cmd_helper.init_api_rate_limit() + for updater in initial_updaters: + if isinstance(updater, PackageUpdater): + ret = updater.refresh(False) + else: + ret = updater.refresh() + if asyncio.iscoroutine(ret): + await ret + self.is_refreshing = False async def _set_klipper_repo(self): kinfo = self.server.get_klippy_info() @@ -139,7 +140,8 @@ class UpdateManager: return kcfg = self.config[f"update_manager static {self.distro} klipper"] self.updaters['klipper'] = GitUpdater(kcfg, self.cmd_helper, kpath, env) - await self.updaters['klipper'].refresh() + async with self.cmd_request_lock: + await self.updaters['klipper'].refresh() async def _check_klippy_printing(self): klippy_apis = self.server.lookup_plugin('klippy_apis')