From ec1416396316145f47797720f8e3d465bb6900b4 Mon Sep 17 00:00:00 2001 From: Jere Date: Sat, 23 May 2026 02:11:43 +0300 Subject: [PATCH] Skip features that fail to load instead of crashing - Wrap module import in Features/__init__.py so a bad import doesn't abort all feature loading - Wrap featureClass() in loadFeatures() so init-time errors (e.g. missing word2vec models) skip that feature with a printed warning instead of taking down the whole app --- Features/__init__.py | 6 +++++- main.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Features/__init__.py b/Features/__init__.py index 3b88f74..3a01e5d 100644 --- a/Features/__init__.py +++ b/Features/__init__.py @@ -4,7 +4,11 @@ import inspect for loader, name, is_pkg in pkgutil.walk_packages(__path__): - module = loader.find_module(name).load_module(name) + try: + module = loader.find_module(name).load_module(name) + except Exception as e: + print("Skipping feature module {}: {}".format(name, e)) + continue for name, value in inspect.getmembers(module): if name.endswith('Feature'): diff --git a/main.py b/main.py index f4c31ad..06b2f43 100644 --- a/main.py +++ b/main.py @@ -53,7 +53,11 @@ def loadFeatures(): classes = inspect.getmembers(sys.modules["Features"], inspect.isclass) for featureName, featureClass in classes: - feature = featureClass(); + try: + feature = featureClass() + except Exception as e: + print("Skipping feature {}: {}".format(featureName, e)) + continue for cmd in feature.cmdpairs: commands[cmd] = feature.cmdpairs[cmd]