utkarsharma2 commented on issue #34497:
URL: https://github.com/apache/airflow/issues/34497#issuecomment-1739012517

   @cbuffett The issue is fixed in the airflow 2.7.1 by PR - 
https://github.com/apache/airflow/pull/33401. There was another issue in my 
script which led me to think the issue still persists. The below script should 
work without halting the debugging flow on airflow's 2.7.1.
   
   ```
   import time
   import datetime
   from airflow import DAG
   from airflow.sensors.external_task import ExternalTaskSensor
   from airflow.models.taskinstance import State
   from airflow.decorators import task
   from airflow.operators.python_operator import PythonOperator
   
   
   def return_date(dt):
       return dt
   
   
   def print_context(**kwargs):
       """Print the Airflow context and ds variable from the context."""
       count = 1
       while True:
           if count > 5:
               break
           print(kwargs)
           time.sleep(20)
           import ipdb
           ipdb.set_trace()
           count = count + 1
   
   default_args = {
       'owner': 'test',
       'start_date': datetime.datetime(2023, 1, 1)
   }
   dag = DAG(dag_id='DAG-1',
           default_args=default_args,
           schedule='@once',
           catchup=False
       )
   with dag:
       external_task_sensor = ExternalTaskSensor(
           task_id='external_dag_sensor',
           poke_interval=60,
           timeout=300,
           soft_fail=True,
           retries=0,
           external_dag_id="some_dag",
           execution_date_fn=return_date,
           allowed_states=[State.SUCCESS],
           failed_states=[State.FAILED],
           check_existence=True,
           mode="reschedule"
       )
   
       t1 = PythonOperator(
           task_id='print',
           python_callable=print_context,
           op_kwargs={"x": "Apache Airflow"},
           dag=dag,
       )
   
   if __name__ == "__main__" or __name__:
       dag.test()
   ```
   
   
   
   


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