Closed thlmenezes closed 4 years ago
@thlmenezes , just as a clarification, this PR deals with exception handling, right?
@thlmenezes, using this feature of context manager, what happens when we are cannot "yield" an emulator?
@thlmenezes , just as a clarification, this PR deals with exception handling, right?
If a Exception occurs, it should attempt to kill the emulator before breaking the benchmark' execution. I quote from the docs and PEP 343
PEP 343:
with VAR = EXPR: BLOCK
which roughly translates into this:
VAR = EXPR VAR.__enter__() try: BLOCK finally: VAR.__exit__()
Docs:
" the exception will be processed normally upon exit from this method "
StackOverflow Answer: https://stackoverflow.com/questions/28157929/how-to-safely-handle-an-exception-inside-a-context-manager#28158006
@thlmenezes, using this feature of context manager, what happens when we are cannot "yield" an emulator?
It will be handled by the try/catch/finally inside the context manager: the finally clause, from the python docs:
"If finally is present, it specifies a ‘cleanup’ handler. The try clause is executed, including any except and else clauses. If an exception occurs in any of the clauses and is not handled, the exception is temporarily saved. The finally clause is executed. If there is a saved exception it is re-raised at the end of the finally clause. If the finally clause raises another exception, the saved exception is set as the context of the new exception. If the finally clause executes a return, break or continue statement, the saved exception is discarded"
Source: https://docs.python.org/3/reference/compound_stmts.html?highlight=finally#the-try-statement
fixes #24