Skip to content

Commit

Permalink
changed module not found error to a warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jsl12 committed Jan 30, 2025
1 parent f120c24 commit 1e0c24a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions appdaemon/app_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ async def start_app(self, app_name: str):
else:
self.objects[app_name].running = True


async def stop_app(self, app_name: str, delete: bool = False) -> bool:
"""Stops the app
Expand Down Expand Up @@ -923,15 +922,20 @@ async def _start_apps(self, update_actions: UpdateActions):
async def safe_create(self: "AppManagement"):
try:
await self.create_app_object(app_name)
except ModuleNotFoundError as e:
update_actions.apps.failed.add(app_name)
self.logger.warning(f"Failed to import module for '{app_name}': {e}")
except Exception:
update_actions.apps.failed.add(app_name)
raise
raise # any exceptions will be handled by the warning_decorator

await safe_create(self)

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

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

@utils.warning_decorator(error_text=f"Error importing '{module_name}'")
async def safe_import(self):
async def safe_import(self: "AppManagement"):
try:
await self.import_module(module_name)
except Exception:
Expand Down

0 comments on commit 1e0c24a

Please sign in to comment.