From b9c85c02e2da50f5bf29ddaf566ddb99c200a70f Mon Sep 17 00:00:00 2001 From: xs5871 Date: Mon, 6 Mar 2023 20:44:46 +0000 Subject: [PATCH] Remove modules and extension that fail during_bootup --- kmk/kmk_keyboard.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kmk/kmk_keyboard.py b/kmk/kmk_keyboard.py index 3a0b25d..e5a6f9c 100644 --- a/kmk/kmk_keyboard.py +++ b/kmk/kmk_keyboard.py @@ -524,18 +524,24 @@ class KMKKeyboard: self._init_matrix() self._init_coord_mapping() - for module in self.modules: + # Modules and extensions that fail `during_bootup` get removed from + # their respective lists. This serves as a self-check mechanism; any + # modules or extensions that initialize peripherals or data structures + # should do that in `during_bootup`. + for idx, module in enumerate(self.modules): try: module.during_bootup(self) except Exception as err: if debug.enabled: debug(f'Failed to load module {module}: {err}') - for ext in self.extensions: + del self.modules[idx] + for idx, ext in enumerate(self.extensions): try: ext.during_bootup(self) except Exception as err: if debug.enabled: debug(f'Failed to load extensions {module}: {err}') + del self.extensions[idx] if debug.enabled: debug(f'init: {self}')