【发布时间】:2021-11-09 19:28:01
【问题描述】:
我有一个任务,我希望它每天只触发一次。我的问题是它会在时机成熟时多次触发。所以每日任务运行 4 次而不是一次。 我设置了一些配置来解决这个问题,包括:
'retries': 1
catchup=False, max_active_runs=1
我还增加了退休之间的时间,认为气流可能认为任务已失败/未开始,因为完成任务可能需要一些时间。
我还根据 answer 将应该在该 dag 中运行的所有代码移至 utils 文件夹
但我不知道我在这里错过了什么。有人可以帮忙吗?提前谢谢你。
这里是dag
from datetime import datetime, timedelta
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from utils.postgres import postgres_backup_to_s3
default_args = {
'retries': 1,
'retry_delay': timedelta(minutes=30),#getting backup and uploading to s3 might take some time
'start_date': datetime(2021, 1, 1)
}
with DAG('postgres_backup', default_args=default_args, schedule_interval='0 19 * * * *',
catchup=False, max_active_runs=1) as dag:
postgres_backup_to_s3_task = PythonOperator(task_id="postgres_backup_to_s3", python_callable=postgres_backup_to_s3)
【问题讨论】:
标签: python airflow airflow-scheduler airflow-api