如何定义 Apache Airflow DAG 的超时?

2024-02-21

我使用的是 Airflow 1.10.2,但 Airflow 似乎忽略了我为 DAG 设置的超时。

我正在使用以下命令为 DAG 设置超时期限dagrun_timeout参数(例如 20 秒),我有一个需要 2 分钟才能运行的任务,但 Airflow 将 DAG 标记为成功!

args = {
    'owner': 'me',
    'start_date': airflow.utils.dates.days_ago(2),
    'provide_context': True,
}

dag = DAG(
    'test_timeout',
     schedule_interval=None,
     default_args=args,
     dagrun_timeout=timedelta(seconds=20),
)

def this_passes(**kwargs):
    return

def this_passes_with_delay(**kwargs):
    time.sleep(120)
    return

would_succeed = PythonOperator(
    task_id='would_succeed',
    dag=dag,
    python_callable=this_passes,
    email=to,
)

would_succeed_with_delay = PythonOperator(
    task_id='would_succeed_with_delay',
    dag=dag,
    python_callable=this_passes_with_delay,
    email=to,
)

would_succeed >> would_succeed_with_delay

不会抛出任何错误消息。我使用了不正确的参数吗?


如中所述源代码 https://github.com/apache/airflow/blob/master/airflow/models/dag.py#L138-L141:

:param dagrun_timeout: specify how long a DagRun should be up before
    timing out / failing, so that new DagRuns can be created. The timeout
    is only enforced for scheduled DagRuns, and only once the
    # of active DagRuns == max_active_runs.

所以这可能是您设置的预期行为schedule_interval=None。这里的想法是确保计划的 DAG 不会永远持续并阻止后续的运行实例。

现在,您可能对execution_timeout https://github.com/apache/airflow/blob/master/airflow/models/baseoperator.py#L167-L168所有运营商均可用。 例如,您可以在您的设备上设置 60 秒超时PythonOperator像这样:

would_succeed_with_delay = PythonOperator(task_id='would_succeed_with_delay',
                            dag=dag,
                            execution_timeout=timedelta(seconds=60),
                            python_callable=this_passes_with_delay,
                            email=to)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何定义 Apache Airflow DAG 的超时? 的相关文章

随机推荐

  • 防止 cl.exe 打印编译后的源文件

    我从命令行 VS 2008 使用MS编译器 每当它编译一个源文件时 它就会打印编译后的源文件 有没有办法避免这种无用的打印 无法使用开关抑制该消息 另请参阅这个线程 http social msdn microsoft com Forums
  • jpa 查询不会触发 hibernate envers

    我正在使用 hibernate envers 来审计事件 当我调用 repositoy delete 或repository save 时 它与 Spring Data JPA Repository 一起工作得很好 但是如果我编写一个 jp
  • 离线撤销模式

    我的问题类似于this https stackoverflow com questions 13560140 verifying certificate using crl certificate revocation list in c
  • 为什么人们会考虑使用代理键而不是自然键和 ON UPDATE CASCADE ?

    免责声明 这与其他主题不是同一个问题 使用自然键时我们面临的缺点之一是 如果业务逻辑发生变化并且我们需要更改一个键 则需要将这一更改传播到所有链接表 然而 使用一个关于级联更新 https stackoverflow com questio
  • Powershell 5 类的 Pester 模拟方法

    我在尝试模拟 powershell 5 类方法时遇到问题 在执行测试时 出现错误 CommandNotFoundException 无法找到 Command FunctionToMock 我试图通过模拟 FunctionToMock 来对
  • '__proxy__' 对象在 CreateView 中没有属性 'get'

    所以我认为这不是正确的做事方式 但我正在尝试学习 django 并且我正在尝试一些事情 我正在尝试为我的设置一个外键Formula模型 通过在实例中硬编码maker Models class Cooker models Model name
  • 具有更高种类类型的类的自类型注释

    Given abstract class Databases F 我怎样才能让这个特质发挥作用 Marker trait signalling the database plugin supports StaticRoles trait S
  • 仅 Web API v2 项目的 HttpContext.Current.User null

    我的目标是将 IWA 集成 Windows 身份验证 与 NET Web API 结合使用 我想将该项目保留为 Web API 项目 而不使用 MVC 我在 Visual Studio 2013 Premium 中创建了两个项目 第一个我选
  • 已处理的 RoutedEvent 继续在树中冒泡

    我正在开发一个TreeView基于控制和我的双击事件继续冒泡我的TreeViewItem nodes 目标是拥有TreeViewItem双击时展开或折叠 我有一种样式 将事件处理程序应用于MouseDoubleClick事件给每个TreeV
  • Swing 不显示 unicode 字符

    I ve got some non ascii characters I m trying to display in a Swing JComboBox The characters aren t displaying correctly
  • 通过 Git 部署的计划 Azure WebJob 导致按需作业

    我有一个支持 Git 的 ASP NET WebApp 以及一个关联的 Azure WebJob 当我通过 Visual Studio 部署它时 一切都很好 但这在持续交付环境中有点困难 所以我想通过 Git 发布 Web 应用程序和 We
  • Kafka 流处理器上下文中的周期性 NPE

    使用 kafka streams 0 10 0 0 在转发消息时 我会定期在 StreamTask 中看到空指针异常 它在 10 到 50 的调用之间变化 NPE 发生在这个方法中 public
  • 适用于 Windows 的 Docker 的 Docker 日志(驱动程序 json 文件)位置

    我想找到容器的日志位置 I use 适用于 Windows 的 Docker 桌面 我知道在linux上他们在 var lib docker containers 但它在哪里呢 它是否隐藏在无法访问的虚拟机中的某个位置 Windows 10
  • VueJS 与 HAML/Jade/Pug 类似的模板

    我同时使用 Vue js 和HAML https www npmjs com package haml在我当前的项目中 模板由 HAML 解析 转换为 HTML 然后由 Vue 解析 例如 pagecontent nonscrolling
  • Spring JPA 选择特定列

    我正在使用 Spring JPA 执行所有数据库操作 但是我不知道如何从 Spring JPA 中的表中选择特定列 例如 SELECT projectId projectName FROM projects 您可以使用 Spring Dat
  • 使用nodemailer在node.js中发送邮件

    我正在尝试使用 Nodemailer 在 node js 中发送邮件 但它显示一些错误 例如 Error self signed certificate in certificate chain code ECONNECTION comma
  • 将 css 边框设置为 90 度而不是 45 度角

    我有一个 div 其 border bottom 和 border right 属性具有不同的颜色 因此 它们通过一条线分开 使盒子呈 45 度角 如何使底部边框更短 以便右边框一直延伸到元素的底部 从而产生 90 度角分隔线 你可以这样做
  • 是否可以将 vb.net 源代码转换为 C++ 代码?

    是否有任何工具将 vb net 源代码转换为 C 例如 gnu C 我知道 Mono 可以将项目转移到不同的平台 但我宁愿转换源代码 既然我们都知道 net 使用自己的二进制库 其他编译器无法使用 是否有任何工具至少可以将 vb net 转
  • 如何在 wiki api 中获取图像 URL?

    当我调用 wiki API 来访问图像 URL 时 我得到这样的图像 URL File Ad tech London 2010 2 JPG 如何从 wiki API 获取该文件的正确 URL 除此之外 关于图像 缩略图 URL 的文档很少T
  • 如何定义 Apache Airflow DAG 的超时?

    我使用的是 Airflow 1 10 2 但 Airflow 似乎忽略了我为 DAG 设置的超时 我正在使用以下命令为 DAG 设置超时期限dagrun timeout参数 例如 20 秒 我有一个需要 2 分钟才能运行的任务 但 Airf