kaxil opened a new pull request, #73297: URL: https://github.com/apache/airflow/pull/73297
`FileSensor.execute` runs the blocking poke loop for the non-deferrable path and then falls through into the deferrable branch, which pokes a second time. So a sensor left at the default `deferrable=False` can still call `self.defer()`: the sync path returns as soon as `poke` finds the file, and if a consumer moves or deletes it before that second poke, the sensor defers. On a deployment running no triggerer the task then sits in `deferred` until `execution_timeout` instead of succeeding. Even with no race at all, every non-deferrable run pays for one extra glob or `os.walk`. Making the second branch an `elif` fixes it, since the two paths were always meant to be exclusive. `ExternalTaskSensor.execute` already has that shape and is annotated `-> None` in the same way. **Why not `return super().execute(...)`**, which is what `TimeDeltaSensor.execute` does and is the smaller diff: that method is annotated `-> Any`, whereas `FileSensor.execute` is `-> None`, and `BaseSensorOperator.execute` returns `Any`. Returning it here would mean a `-> None` method handing back a value. The branch form matches both this method's annotation and the nearer sibling. The added test patches `poke` with `side_effect=[True, False]` and asserts a single call. With the second `if` restored it fails with `TaskDeferred`, which is the behaviour being fixed. -- 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]
