vashisht33 opened a new issue, #39910:
URL: https://github.com/apache/airflow/issues/39910
### Apache Airflow version
2.9.1
### If "Other Airflow 2 version" selected, which one?
_No response_
### What happened?
wait_for_completion not working when set to True while triggering child dag
from parent dag.Below i have shared two files,one is parent_dag and other is
child_dag.All i am trying to do is to trigger child dag from parent dag and
wait for completion of child dag before i proceed further in parent_dag(to next
task in line).But my child_dag gets in queued state and then scheduler starts
skipping heartbeat,although there is no issue in the code as i was able to
trigger child dag manually.Also,when i set wait_for_completion = False,it ran
fine.
### What you think should happen instead?
_No response_
### How to reproduce
parent_dag.py
from airflow import DAG
from airflow.operators.dagrun_operator import TriggerDagRunOperator
from airflow.operators.python_operator import PythonOperator
from datetime import datetime, timedelta
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime(2024, 5, 27),
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
}
parent_dag = DAG(
'parent_dag',
default_args=default_args,
schedule_interval='@daily',
catchup=False
)
def c():
print("c")
trigger_target = TriggerDagRunOperator(
task_id='trigger_target',
trigger_dag_id='child_dag',
reset_dag_run=True,
wait_for_completion=True,
poke_interval=10,
dag = parent_dag
)
task_after_child_dag_completion = PythonOperator(
task_id = "task_after_child_dag_completion",
python_callable = c,
dag = parent_dag
)
trigger_target >> task_after_child_dag_completion
child_dag.py
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from datetime import datetime, timedelta
import time
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime(2024, 5, 27),
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
}
child_dag = DAG(
'child_dag',
default_args=default_args,
schedule_interval=None,
catchup=False
)
def child_task():
time.sleep(15)
print("Executing child task")
child_task = PythonOperator(
task_id='child_task',
python_callable=child_task,
dag=child_dag
)
child_task
### Operating System
Ubuntu 22.04.4 LTS
### Versions of Apache Airflow Providers
_No response_
### Deployment
Other
### Deployment details
local env
### Anything else?
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]