Skip to content

Commit 1e0c24a

Browse files
committed
changed module not found error to a warning
1 parent f120c24 commit 1e0c24a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

appdaemon/app_management.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ async def start_app(self, app_name: str):
368368
else:
369369
self.objects[app_name].running = True
370370

371-
372371
async def stop_app(self, app_name: str, delete: bool = False) -> bool:
373372
"""Stops the app
374373
@@ -923,15 +922,20 @@ async def _start_apps(self, update_actions: UpdateActions):
923922
async def safe_create(self: "AppManagement"):
924923
try:
925924
await self.create_app_object(app_name)
925+
except ModuleNotFoundError as e:
926+
update_actions.apps.failed.add(app_name)
927+
self.logger.warning(f"Failed to import module for '{app_name}': {e}")
926928
except Exception:
927929
update_actions.apps.failed.add(app_name)
928-
raise
930+
raise # any exceptions will be handled by the warning_decorator
929931

930932
await safe_create(self)
931933

932934
# Need to have already created the ManagedObjects for the threads to get assigned
933935
await self.AD.threading.calculate_pin_threads()
934936

937+
# Need to recalculate start order in case creating the app object fails
938+
start_order = update_actions.apps.start_sort(self.dependency_manager)
935939
for app_name in start_order:
936940
if isinstance((cfg := self.app_config.root[app_name]), AppConfig):
937941
rel_path = cfg.config_path.relative_to(self.AD.app_dir.parent)
@@ -963,7 +967,7 @@ async def _import_modules(self, update_actions: UpdateActions) -> Set[str]:
963967
for module_name in load_order:
964968

965969
@utils.warning_decorator(error_text=f"Error importing '{module_name}'")
966-
async def safe_import(self):
970+
async def safe_import(self: "AppManagement"):
967971
try:
968972
await self.import_module(module_name)
969973
except Exception:

0 commit comments

Comments
 (0)