This is an automated email from the ASF dual-hosted git repository.

weilee pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 43cd2d1ab43 refactor(hitl): replace timezone usage with 
airflow.sdk.timezone (#53962)
43cd2d1ab43 is described below

commit 43cd2d1ab43bceee375f69306cf15f71aa3cbfb3
Author: Wei Lee <[email protected]>
AuthorDate: Mon Aug 4 17:35:37 2025 +0800

    refactor(hitl): replace timezone usage with airflow.sdk.timezone (#53962)
---
 providers/standard/src/airflow/providers/standard/operators/hitl.py | 4 ++--
 providers/standard/src/airflow/providers/standard/triggers/hitl.py  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/providers/standard/src/airflow/providers/standard/operators/hitl.py 
b/providers/standard/src/airflow/providers/standard/operators/hitl.py
index b0d73ff02cd..35f7703cee6 100644
--- a/providers/standard/src/airflow/providers/standard/operators/hitl.py
+++ b/providers/standard/src/airflow/providers/standard/operators/hitl.py
@@ -26,7 +26,6 @@ if not AIRFLOW_V_3_1_PLUS:
 
 
 from collections.abc import Collection, Mapping
-from datetime import datetime, timezone
 from typing import TYPE_CHECKING, Any
 
 from airflow.providers.standard.exceptions import HITLTimeoutError, 
HITLTriggerEventError
@@ -36,6 +35,7 @@ from airflow.providers.standard.utils.skipmixin import 
SkipMixin
 from airflow.providers.standard.version_compat import BaseOperator
 from airflow.sdk.definitions.param import ParamsDict
 from airflow.sdk.execution_time.hitl import upsert_hitl_detail
+from airflow.sdk.timezone import utcnow
 
 if TYPE_CHECKING:
     from airflow.sdk.definitions.context import Context
@@ -109,7 +109,7 @@ class HITLOperator(BaseOperator):
             params=self.serialized_params,
         )
         if self.execution_timeout:
-            timeout_datetime = datetime.now(timezone.utc) + 
self.execution_timeout
+            timeout_datetime = utcnow() + self.execution_timeout
         else:
             timeout_datetime = None
         self.log.info("Waiting for response")
diff --git a/providers/standard/src/airflow/providers/standard/triggers/hitl.py 
b/providers/standard/src/airflow/providers/standard/triggers/hitl.py
index 17c81847247..87dfc57ab07 100644
--- a/providers/standard/src/airflow/providers/standard/triggers/hitl.py
+++ b/providers/standard/src/airflow/providers/standard/triggers/hitl.py
@@ -34,8 +34,8 @@ from airflow.sdk.execution_time.hitl import (
     get_hitl_detail_content_detail,
     update_htil_detail_response,
 )
+from airflow.sdk.timezone import utcnow
 from airflow.triggers.base import BaseTrigger, TriggerEvent
-from airflow.utils import timezone
 
 
 class HITLTriggerEventSuccessPayload(TypedDict, total=False):
@@ -97,7 +97,7 @@ class HITLTrigger(BaseTrigger):
     async def run(self) -> AsyncIterator[TriggerEvent]:
         """Loop until the Human-in-the-loop response received or timeout 
reached."""
         while True:
-            if self.timeout_datetime and self.timeout_datetime < 
timezone.utcnow():
+            if self.timeout_datetime and self.timeout_datetime < utcnow():
                 if self.defaults is None:
                     yield TriggerEvent(
                         HITLTriggerEventFailurePayload(

Reply via email to