hussein-awala commented on issue #56204:
URL: https://github.com/apache/airflow/issues/56204#issuecomment-3349166639

   I confirm the bug — I was able to reproduce it on the main branch. It looks 
like the issue is related to the `try/except` context (or any context). The 
other DAG is triggered with 3.1.0+ if we remove the `try/except` block and keep 
only the `TriggerDagRunOperator`, but the operator is called once, which means 
there’s a short-circuit in the task runner that stops the loop:
   ```python
       @task
       def schedule_dags(**kwargs):
           for i in range(5):
               execution_date = datetime.datetime.utcnow() + 
datetime.timedelta(minutes=5)
               logging.info(f"Trigger report for counter #{i} at 
'{execution_date}'")
               TriggerDagRunOperator(task_id=f"create_reports_dag_{i}"
                                     , trigger_dag_id="Create-Reports"
                                     , conf={"counter": i}
                                     # , 
logical_date=execution_date.replace(tzinfo=pytz.UTC),
                                     ).execute(context=kwargs)
   ```
   logs:
   ```
   Log message source details 
sources=["/root/airflow/logs/dag_id=Task-Run-Demo/run_id=manual__2025-09-29T21:30:50.712933+00:00/task_id=schedule_dags/attempt=1.log"]
   INFO - DAG bundles loaded: dags-folder
   INFO - Filling up the DagBag from /files/dags/56204.py
   INFO - Trigger report for counter #0 at '2025-09-29 21:35:51.792317'
   WARNING - TriggerDagRunOperator.execute cannot be called outside of the Task 
Runner!
   INFO - Triggering Dag Run. trigger_dag_id=Create-Reports
   INFO - Dag Run triggered successfully. trigger_dag_id=Create-Reports
   ```
   Why the warning message?
   in this code:
   ```
   if not cls.test_mode and sentinel is not self:
   ```
   self is `<Task(TriggerDagRunOperator): create_reports_dag_0>` but `sentinel` 
is `<Task(_PythonDecoratedOperator): schedule_dags>`


-- 
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]

Reply via email to