airflow.sensors.base_sensor_operator

Module Contents

class airflow.sensors.base_sensor_operator.BaseSensorOperator(poke_interval=60, timeout=60 * 60 * 24 * 7, soft_fail=False, mode='poke', *args, **kwargs)[source]

Bases: airflow.models.BaseOperator, airflow.models.SkipMixin

Sensor operators are derived from this class and inherit these attributes.

Sensor operators keep executing at a time interval and succeed when a criteria is met and fail if and when they time out.

Parameters
  • soft_fail (bool) – Set to true to mark the task as SKIPPED on failure

  • poke_interval (int) – Time in seconds that the job should wait in between each tries

  • timeout (int) – Time, in seconds before the task times out and fails.

  • mode (str) – How the sensor operates. Options are: { poke | reschedule }, default is poke. When set to poke the sensor is taking up a worker slot for its whole execution time and sleeps between pokes. Use this mode if the expected runtime of the sensor is short or if a short poke interval is required. Note that the sensor will hold onto a worker slot and a pool slot for the duration of the sensor’s runtime in this mode. When set to reschedule the sensor task frees the worker slot when the criteria is not yet met and it’s rescheduled at a later time. Use this mode if the time before the criteria is met is expected to be quite long. The poke interval should be more than one minute to prevent too much load on the scheduler.

ui_color = #e6f1f2[source]
valid_modes = ['poke', 'reschedule'][source]
reschedule[source]
deps[source]

Adds one additional dependency for all sensor operators that checks if a sensor task instance can be rescheduled.

_validate_input_values(self)[source]
poke(self, context)[source]

Function that the sensors defined while deriving this class should override.

execute(self, context)[source]
_do_skip_downstream_tasks(self, context)[source]