You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to always run cleanup code when a task fails. I didn't know how to accomplish that until I realized that sessions fail when session.runs raise CommandFailed. The use of exceptions here means I can cleanup by using a finally block. For example,
Thanks for catching this! Indeed, the documentation is not explicit about what happens when a command run via session.run fails. This could be a sentence added to the docstring of nox.sessions.Session.run.
I also agree that the pattern of wrapping a try...finally around session.run for cleanup actions is worth mentioning. Not sure about mentioning CommandFailed specifically, as it's currently not part of the public API. Maybe for now it's enough to just say that an exception is raised that causes Nox to mark the session as failed?
How would this feature be useful?
I need to always run cleanup code when a task fails. I didn't know how to accomplish that until I realized that sessions fail when
session.run
s raiseCommandFailed
. The use of exceptions here means I can cleanup by using a finally block. For example,Describe the solution you'd like
Taking the outcome of #516 into account, documenting that this is possible may help other users learn understand what is possible.
The text was updated successfully, but these errors were encountered: