YiiTing commented on issue #40679:
URL: https://github.com/apache/airflow/issues/40679#issuecomment-2244115741

   Hello [gyli](https://github.com/gyli),
   
   Here is code.
   When don't set timezone in start_date, airflow.cfg set `default_timezone in 
'Asia/Taipei'`, and can find timezone with 'Asia/Taipei' in DAG Details, but 
TimeSensor can't stop after two minutes.
   
   ```
   from airflow.decorators import dag
   from airflow.sensors.time_sensor import TimeSensor
   from airflow.timetables.trigger import CronTriggerTimetable
   
   import datetime, pendulum, textwrap
   
   
   @dag(dag_id="example_dags",
        schedule=CronTriggerTimetable("0 0 * * *", timezone="Asia/Taipei"),
        start_date=pendulum.datetime(2024, 1, 1),
        default_args={
            'owner': "airflow",
            'retries': 3,
            'retry_delay': datetime.timedelta(minutes=10),
            'depends_on_past': False
        },
        catchup=False,
        tags=["example"])
   def generate_dag():
       delay_2m = TimeSensor(
           task_id="delay_2m",
           target_time=(pendulum.now("Asia/Taipei") + 
datetime.timedelta(minutes=2)).time(),
           poke_interval=datetime.timedelta(minutes=1),
           timeout=datetime.timedelta(minutes=10))
       
       
   generate_dag()
   ```
   
   and here is ouput 
   ```
   [2024-07-23, 09:51:44 CST] {local_task_job_runner.py:120}  Pre task 
execution logs
   [2024-07-23, 09:51:44 CST] {time_sensor.py:48} INFO - Checking if the time 
(09:53:44.546664) has come
   [2024-07-23, 09:52:44 CST] {time_sensor.py:48} INFO - Checking if the time 
(09:53:44.546664) has come
   [2024-07-23, 09:53:44 CST] {time_sensor.py:48} INFO - Checking if the time 
(09:53:44.546664) has come
   [2024-07-23, 09:54:45 CST] {time_sensor.py:48} INFO - Checking if the time 
(09:53:44.546664) has come
   ```
   


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