开发者

Custom Airflow Operator try-except-finally block not working

开发者 https://www.devze.com 2022-12-07 17:42 出处:网络
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.

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

精彩评论

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