o-nikolas commented on issue #26196: URL: https://github.com/apache/airflow/issues/26196#issuecomment-1281579978
> when job get completed successfully it return value by using return statement (that will not execute finally block) and similarly in case of failure it will raise exception that will also not execute the finally block. Is this really true? From Python docs [here](https://docs.python.org/3/tutorial/errors.html#defining-clean-up-actions): > If a [finally](https://docs.python.org/3/reference/compound_stmts.html#finally) clause is present, the finally clause will execute as the last task before the [try](https://docs.python.org/3/reference/compound_stmts.html#try) statement completes. The finally clause runs whether or not the try statement produces an exception. The following points discuss more complex cases when an exception occurs: > - If an exception occurs during execution of the try clause, the [except](https://docs.python.org/3/reference/compound_stmts.html#except)ion may be handled by an except clause. If the exception is not handled by an except clause, the exception is re-raised after the finally clause has been executed. > - An exception could occur during execution of an except or else clause. Again, the exception is re-raised after the finally clause has been executed. > - If the try statement reaches a [break](https://docs.python.org/3/reference/simple_stmts.html#break), [continue](https://docs.python.org/3/reference/simple_stmts.html#continue) or [return](https://docs.python.org/3/reference/simple_stmts.html#return) statement, the finally clause will execute just prior to the break, continue or return statement’s execution. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
