t4 = BashOperator( task_id='sleep_to_be_stopped', bash_command='sleep 100', dag=dag, event_handler=ActionEventHandler() ) def my_sleeping_function(random_base): """This is a function that will run within the DAG execution""" time.sleep(random_base) t3 = PythonOperator( task_id='python_sleep', python_callable=my_sleeping_function, op_kwargs={'random_base': 100}, dag=dag, event_handler=ActionEventHandler() ) t3.subscribe_event('start', '', event_namespace='test_namespace') t3.subscribe_event(event_key="restart", event_namespace='test_namespace', event_type=UNDEFINED_EVENT_TYPE, from_task_id='sleep_to_be_stopped') dag.doc_md = __doc__ t1 >> [t2, t3, t4]
event_handler=ActionEventHandler()) t2.subscribe_event('start', '', event_namespace='test_namespace') t2.subscribe_event(event_key="stop", event_namespace='test_namespace', event_type=UNDEFINED_EVENT_TYPE) t4 = BashOperator(task_id='sleep_to_be_stopped', bash_command='sleep 100', dag=dag, event_handler=ActionEventHandler()) def my_sleeping_function(random_base): """This is a function that will run within the DAG execution""" time.sleep(random_base) t3 = PythonOperator(task_id='python_sleep', python_callable=my_sleeping_function, op_kwargs={'random_base': 100}, dag=dag, event_handler=ActionEventHandler()) t3.subscribe_event('start', '', event_namespace='test_namespace') t3.subscribe_event(event_key="restart", event_namespace='test_namespace', event_type=UNDEFINED_EVENT_TYPE) dag.doc_md = __doc__ t1 >> [t2, t3, t4]