liveBook · Manning

Polling

As explained in Data Pipelines with Apache Airflow, Second Edition

Polling is the technique of repeatedly checking an external system or condition at intervals until a desired state is observed.

Polling repeatedly checks an external condition until it becomes true or a timeout is reached. In Airflow, sensors use polling to detect data availability without delaying an entire workflow unnecessarily. section 7.1

Airflow polling behaves as follows:

  • A sensor checks a condition, such as whether a file exists. section 7.1
  • A false result causes the sensor to wait and try again after the configured interval. section 7.1
  • A true result moves the task to Success; continued failure ends when the configured timeout is reached. section 7.1
  • Very short intervals can overload the target system when responses take as long as the polling interval. section 7.1

Waiting for supermarket data

Instead of starting a workflow at 2:00 and leaving it idle while supermarkets deliver data, a FileSensor can repeatedly check for /data/supermarket1/data.csv and begin processing when the file appears. section 7.1

Listing 7.1 A FileSensor waits for a file path to exist
from airflow.providers.standard.sensors.filesystem import FileSensor

wait_for_supermarket_1 = FileSensor(
   task_id="wait_for_supermarket_1",
   filepath="/data/supermarket1/data.csv",
)

Inspect the FileSensor configuration that polls for a file path. section 7.1

How Data Pipelines with Apache Airflow, Second Edition covers it

How deep it goes
Defines condition checks, success and timeout behavior, intervals, and overload risk, but not sensor internals.
Examples
Uses supermarket delivery timelines, a FileSensor, a CSV path, task logs, and configurable poke intervals.
What you can do after
Operate/configure Airflow sensors to wait for files and control checking intervals and timeouts.
How it connects
Connects sensors, operators, DAGs, task states, timeouts, and workflow scheduling.

Also explained in

Compare how 9 books explain polling →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Pipelines with Apache Airflow, Second Edition. The section links point to the parts of the book it draws on.