RehanAhmad25 commented on code in PR #69925:
URL: https://github.com/apache/airflow/pull/69925#discussion_r3652980277


##########
providers/standard/src/airflow/providers/standard/sensors/time.py:
##########
@@ -101,10 +105,9 @@ def execute_complete(self, context: Context, event: Any = 
None) -> None:
         return None
 
     def poke(self, context: Context) -> bool:
-        self.log.info("Checking if the time (%s) has come", 
self.target_datetime)
-
-        # self.target_date has been converted to UTC, so we do not need to 
convert timezone
-        return timezone.utcnow() > self.target_datetime
+        target_datetime = self.target_datetime
+        self.log.info("Checking if the time (%s) has come", target_datetime)
+        return timezone.utcnow() > target_datetime

Review Comment:
   This one's intentional, your parenthetical guess is right. target_datetime 
is now a computed property (calls datetime.now() fresh on every access), so 
calling self.target_datetime twice in this method could return two slightly 
different instants if the wall clock ticks past the target moment between the 
log call and the comparison. Storing it in a local variable once guarantees the 
logged value and the compared value are the same instant. I'd like to keep this 
as-is rather than revert, let me know if you still see it differently.



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