From 9356233762a67c0a787fc3e16040455019af13bd Mon Sep 17 00:00:00 2001 From: Phong Bui <59940078+boushphong@users.noreply.github.com> Date: Thu, 9 Nov 2023 07:56:44 +0700 Subject: [PATCH] Avoid initiating session twice in dag_next_execution (#35539) --- airflow/cli/commands/dag_command.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/airflow/cli/commands/dag_command.py b/airflow/cli/commands/dag_command.py index 064da35df155c..74609c41dc5be 100644 --- a/airflow/cli/commands/dag_command.py +++ b/airflow/cli/commands/dag_command.py @@ -320,14 +320,14 @@ def dag_next_execution(args) -> None: """ dag = get_dag(args.subdir, args.dag_id) - if dag.get_is_paused(): - print("[INFO] Please be reminded this DAG is PAUSED now.", file=sys.stderr) - with create_session() as session: last_parsed_dag: DagModel = session.scalars( select(DagModel).where(DagModel.dag_id == dag.dag_id) ).one() + if last_parsed_dag.get_is_paused(): + print("[INFO] Please be reminded this DAG is PAUSED now.", file=sys.stderr) + def print_execution_interval(interval: DataInterval | None): if interval is None: print(