You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "sanket2000 (via GitHub)" <gi...@apache.org> on 2024/06/04 05:24:36 UTC

Re: [PR] Exponential Backoff Not Functioning in BaseSensorOperator Reschedule Mode [airflow]

sanket2000 commented on code in PR #39823:
URL: https://github.com/apache/airflow/pull/39823#discussion_r1625362795


##########
airflow/sensors/base.py:
##########
@@ -344,6 +344,37 @@ def _get_next_poke_interval(
         if not self.exponential_backoff:
             return self.poke_interval
 
+        if self.reschedule:
+            # Calculate elapsed time since the sensor started
+            elapsed_time = run_duration()
+
+            # Initialize variables for the simulation
+            cumulative_time = 0
+            estimated_poke_count = 0
+
+            while cumulative_time < elapsed_time:
+                estimated_poke_count += 1
+                # Calculate min_backoff for the current try number
+                min_backoff = max(int(self.poke_interval * (2 ** (estimated_poke_count - 1))), 1)
+
+                # Calculate the jitter

Review Comment:
   included the comment suggestion in the latest commit, Thanks



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org