Skip to content

Commit

Permalink
Merge pull request #73 from canvas-medical/ad/prevent-boot-looping
Browse files Browse the repository at this point in the history
Prevent bootlooping due to a failed plugin load.
  • Loading branch information
aduane authored Jul 16, 2024
2 parents 264f8b2 + aa3379b commit 978eae8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions plugin_runner/plugin_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def load_or_reload_plugin(path: pathlib.Path) -> None:
try:
manifest_json = json.loads(manifest_json)
except Exception as e:
log.warning(f'Unable to load plugin "{name}": {e}')
log.error(f'Unable to load plugin "{name}": {e}')
return

secrets_file = path / SECRETS_FILE_NAME
Expand All @@ -162,13 +162,13 @@ def load_or_reload_plugin(path: pathlib.Path) -> None:
try:
secrets_json = json.load(secrets_file.open())
except Exception as e:
log.warning(f'Unable to load secrets for plugin "{name}": {str(e)}')
log.error(f'Unable to load secrets for plugin "{name}": {str(e)}')

# TODO add existing schema validation from Michela here
try:
protocols = manifest_json["components"]["protocols"]
except Exception as e:
log.warning(f'Unable to load plugin "{name}": {str(e)}')
log.error(f'Unable to load plugin "{name}": {str(e)}')
return

for protocol in protocols:
Expand Down Expand Up @@ -204,8 +204,10 @@ def load_or_reload_plugin(path: pathlib.Path) -> None:
"protocol": protocol,
"secrets": secrets_json,
}
except ImportError as err:
except Exception as err:
log.error(f"Error importing module '{name_and_class}': {err}")
for error_line in traceback.format_exception(err):
log.error(error_line)


def refresh_event_type_map() -> None:
Expand Down

0 comments on commit 978eae8

Please sign in to comment.