开发者

Custom Airflow Operator try-except-finally block not working

I am developing a custom Operator in airflow which inherits from an already existing one.

I want to perform an action at the end of the execution even if the execution fails.

So far I tried this in my execute method but it seems it is not working properly, since is not entering the finally block (nor the except one) when there is an error (It does when there is no error)

def execute(self, context):

    try:
        super().execute(context)
    except:
        self.log.info(f'Error Found Except')
        raise
    finally:
        self.log .info(f'Error Found Finally')开发者_如何转开发
        self.clean_workspace(someparams)

Any idea? I need to call clean_workspace method always, no matter if the execute ends in success or in error

Operator is defined as follows:

class MyOperator(DatabricksSubmitRunOperator):
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜