From 186169343d21a2b605cd382b2cb4e02bc62c2ef0 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Thu, 1 Feb 2018 18:44:48 +0100 Subject: [PATCH] [engine] do not fail on module import If a module import fails, simply log a warning. The module, clearly, cannot be used, though. fixes #227 --- bumblebee/engine.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bumblebee/engine.py b/bumblebee/engine.py index c40fc1c..a746db2 100644 --- a/bumblebee/engine.py +++ b/bumblebee/engine.py @@ -216,9 +216,12 @@ class Engine(object): def _read_aliases(self): result = {} for module in all_modules(): - mod = importlib.import_module("bumblebee.modules.{}".format(module["name"])) - for alias in getattr(mod, "ALIASES", []): - result[alias] = module["name"] + try: + mod = importlib.import_module("bumblebee.modules.{}".format(module["name"])) + for alias in getattr(mod, "ALIASES", []): + result[alias] = module["name"] + except Exception as error: + log.warning("failed to import {}: {}".format(module["name"], str(error))) return result def _load_module(self, module_name, config_name=None):