make startup more failsafe

This commit is contained in:
Matthias 2021-11-20 03:29:32 +01:00
parent d36ab0d9cd
commit 8bcdad6a8f
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
2 changed files with 12 additions and 0 deletions

View File

@ -889,6 +889,7 @@ INTEGRATION_PLUGIN_GLOBALSETTING = {}
INTEGRATION_APPS_LOADING = True # Marks if apps were reloaded yet
INTEGRATION_PLUGINS_RELOADING = False
INTEGRATION_APPS_PATHS = [] # Holds all added plugin_paths
INTEGRATION_STARTUP_ERRORS = {} # Holds discovering errors
# Test settings
PLUGIN_TESTING = get_setting('PLUGIN_TESTING', TESTING) # used to force enable everything plugin

View File

@ -41,6 +41,17 @@ def get_modules(pkg, recursive: bool = False):
context[name] = module
except AppRegistryNotReady:
pass
except Exception as error:
# this 'protects' against malformed plugin modules by more or less silently failing
# TODO log
# make sure the registry is set up
if 'discovery' not in settings.INTEGRATION_STARTUP_ERRORS:
settings.INTEGRATION_STARTUP_ERRORS['discovery'] = []
# add error to stack
settings.INTEGRATION_STARTUP_ERRORS['discovery'].append({name: str(error)})
return [v for k, v in context.items()]