From c718e9d1c38f53b56e86d0d2505dfda1075618ba Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Wed, 3 Nov 2021 08:08:28 -0400 Subject: [PATCH] moonraker: don't use a set to load initial components Previously a set was used to remove duplicate components, however this is unnecessary as the `load_component` method immediately returns dups. Using a list should preserve the load order based on the configuration, making it more predictable. Signed-off-by: Eric Callahan --- moonraker/moonraker.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/moonraker/moonraker.py b/moonraker/moonraker.py index 4c09fa9..8156059 100755 --- a/moonraker/moonraker.py +++ b/moonraker/moonraker.py @@ -211,14 +211,17 @@ class Server: self.set_failed_component(name) def _load_components(self, config: confighelper.ConfigHelper) -> None: + cfg_sections = [s.split()[0] for s in config.sections()] + cfg_sections.remove('server') + # load core components for component in CORE_COMPONENTS: self.load_component(config, component) + if component in cfg_sections: + cfg_sections.remove(component) - # check for optional components - opt_sections = set([s.split()[0] for s in config.sections()]) - opt_sections.remove('server') - for section in opt_sections: + # load remaining optional components + for section in cfg_sections: self.load_component(config, section, None) def load_component(self,