重试气流期间如何保持值

编程入门 行业动态 更新时间:2024-10-24 20:15:42
本文介绍了重试气流期间如何保持值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

每次dag触发任务时,我都想生成一个值并在重试期间保留该值(如果任务由于任何原因而无法运行)

Everytime a dag triggers a task I would like to generate a value and keep the value during retry (if the task fails to run for any reason)

我尝试在dag中声明一个变量(基本上将当前时间设置为该变量) 当任务失败并重试时,它会再次将变量设置为最新时间

I try to declare a variable inside the dag (basically set current time to the variable) When the task fails and it retries, it set the variable with latest time again

推荐答案

  • 您可以使用BaseOperator的> on_failure_callback和on_retry_callback参数将要保留的值作为 xcom

    • You can make use of on_failure_callback and on_retry_callback params of BaseOperator to push the value that you want to persist as xcom

      此后,您可以在您的Airflow部署的任何DAG中的任何task中,从Xcom 检索数据,包括相同或不同的task

      Thereafter, you can retrieve that data from Xcom in any task across any DAG of your Airflow deployment, including the retry attempt of same / different task

      也看看

      • 参数更改后的Airflow DAG任务能否重试

      Airflow Task失败/重试工作流程

更多推荐

重试气流期间如何保持值

本文发布于:2023-11-24 03:36:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623831.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:气流   重试

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!