This is an automated email from the ASF dual-hosted git repository.
kaxilnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new b34ba87 TimeSensor should respect the default_timezone config (#9699)
b34ba87 is described below
commit b34ba874452809495354f3012e0b1dcbf4209e09
Author: zikun <[email protected]>
AuthorDate: Sun Jul 19 01:36:28 2020 +0800
TimeSensor should respect the default_timezone config (#9699)
---
UPDATING.md | 6 ++++++
airflow/sensors/time_sensor.py | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/UPDATING.md b/UPDATING.md
index c5097ae..b58eaf1 100644
--- a/UPDATING.md
+++ b/UPDATING.md
@@ -1475,6 +1475,12 @@ arguments, please change `store_serialized_dags` to
`read_dags_from_db`.
Similarly, if you were using `DagBag().store_serialized_dags` property, change
it to
`DagBag().read_dags_from_db`.
+### TimeSensor will consider default_timezone setting.
+
+Previously `TimeSensor` always compared the `target_time` with the current
time in UTC.
+
+Now it will compare `target_time` with the current time in the timezone set by
`default_timezone` under the `core` section of the config.
+
## Airflow 1.10.11
diff --git a/airflow/sensors/time_sensor.py b/airflow/sensors/time_sensor.py
index 210dc00..69feaae 100644
--- a/airflow/sensors/time_sensor.py
+++ b/airflow/sensors/time_sensor.py
@@ -36,4 +36,4 @@ class TimeSensor(BaseSensorOperator):
def poke(self, context):
self.log.info('Checking if the time (%s) has come', self.target_time)
- return timezone.utcnow().time() > self.target_time
+ return timezone.make_naive(timezone.utcnow()).time() > self.target_time