-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure SystemExit is captured on driver initialization #3230
Conversation
Prevent a broken driver from affecting usability of molecule by catching even SystemExit. Related: ansible-community/molecule-podman#81
@@ -51,14 +51,14 @@ def drivers(config=None) -> UserListMap: | |||
pm = pluggy.PluginManager("molecule.driver") | |||
try: | |||
pm.load_setuptools_entrypoints("molecule.driver") | |||
except Exception: | |||
except (Exception, SystemExit): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ssbarnea this doesn't catch everything, though. Is it intentional that you didn't use BaseException
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure what kind of other exceptions would Base Exception catch so I went for that approach. Shortly I don't know if current code is better than just BaseException or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could catch all the exceptions excluding KeyboardInterrupt
, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole hierarchy is documented here: https://docs.python.org/3/library/exceptions.html#exception-hierarchy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OTOH Molecule could also define own exceptions for communicating misconfiguration clearly. In this case, you'd need something like
try:
...
except KeyboardInterrupt:
raise
except MoleculeMisconfiguredException:
report_exc()
except BaseException:
process_exc()
Prevent a broken driver from affecting usability of molecule by catching even SystemExit. Related: ansible-community/molecule-podman#81
This comment has been minimized.
This comment has been minimized.
Backport to stable/3.4: 💚 backport PR created✅ Backport PR branch: Backported as #3253 🤖 @patchback |
Prevent a broken driver from affecting usability of molecule by catching even SystemExit. Related: ansible-community/molecule-podman#81 (cherry picked from commit 5e717ce)
Prevent a broken driver from affecting usability of molecule by catching even SystemExit. Related: ansible-community/molecule-podman#81 (cherry picked from commit 5e717ce)
Prevent a broken driver from affecting usability of molecule by catching even SystemExit.
Related: ansible-community/molecule-podman#81