AVMusorin opened a new issue, #31409:
URL: https://github.com/apache/airflow/issues/31409

   ### Apache Airflow version
   
   2.6.1
   
   ### What happened
   
   Sensor is fired with an exception ZeroDivisionError, if set up 
`mode="reschedule"`, `exponential_backoff=True` and `poke_interval=1` 
   
   ```
   ERROR - Task failed with exception
   Traceback (most recent call last):
     File 
"/home/airflow/.local/lib/python3.9/site-packages/airflow/sensors/base.py", 
line 244, in execute
       next_poke_interval = self._get_next_poke_interval(started_at, 
run_duration, try_number)
     File 
"/home/airflow/.local/lib/python3.9/site-packages/airflow/sensors/base.py", 
line 274, in _get_next_poke_interval
       modded_hash = min_backoff + run_hash % min_backoff
   ZeroDivisionError: integer division or modulo by zero
   ```
   
   ### What you think should happen instead
   
   Throw an human-readable exception about corner values for `poke_interval` or 
allow to set up this value less then 2 (if it's `>=` 2 - rescheduling works 
fine.)
   
   ### How to reproduce
   
   ```
   from airflow.sensors.base import BaseSensorOperator
   from airflow import DAG
   import datetime
   
   class TestSensor(BaseSensorOperator):
       def poke(self, context):
           return False
   
   with DAG("test_dag", start_date=datetime.datetime.today(), schedule=None):
       sensor = TestSensor(task_id="sensor", mode="reschedule", 
poke_interval=1, exponential_backoff=True, max_wait=5)
   ```
   
   ### Operating System
   
   Debian GNU/Linux 10 (buster)
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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