EPAM India QA automation code often needs a resource lifecycle that behaves consistently when an operation succeeds or raises an exception. Implement execute_session(actions) using a Python context manager.
The context manager must record lifecycle events in this order:
"acquire" when the session starts.actions, appending ordinary action names to the event log."fail", raise a ValueError and do not append "fail"."commit" only when every action completes successfully."rollback" when any exception occurs."release" exactly once in all cases, including failures.ValueError inside execute_session and return the event log. Do not suppress exceptions inside the context manager itself.actions, a list of strings containing ordinary action names and optionally one "fail" action."fail" action.def execute_session(actions):