Lesson 14 · Pipeline patterns & best practices
Sensors & deferrable operators
Waiting on the outside world — without wasting a worker slot.
Your win: explain what a sensor is, the poke / reschedule / deferrable modes, and when to use each — a certification topic even though this repo doesn't use them.
A sensor waits for a condition
Pipelines often must wait for something external before proceeding: a source file to
land, a table partition to be ready, another DAG's task to finish. A
sensor is an operator whose job is exactly that — it checks a
condition on an interval and succeeds once it's met.1
Common ones: FileSensor, ExternalTaskSensor (wait for another
DAG), object-storage sensors.
Three ways to wait — cheapest last
| Mode | Behaviour | Use when |
|---|---|---|
| poke (default) | holds a worker slot the whole time, checks periodically | short waits (poke interval < ~5 min) |
| reschedule | releases the slot between checks, re-queues later | long waits — frees workers |
| deferrable | hands the async wait to the triggerer — no slot at all | waiting at scale (Lesson 7) |
SparkKubernetesOperator simply blocks
until its job finishes rather than a separate sensor "waiting" for it. So there's no repo
example here — but the certification tests sensors, and any pipeline that depends on an
external signal (a daily file, an upstream DAG) will eventually need one. Learn the concept
and the poke/reschedule/deferrable trade-off.
Airflow — Sensors (+ Astronomer's sensor guide)
The sensor concept, poke vs reschedule, and how deferrable operators improve on both.
→ airflow.apache.org — Sensors
→ astronomer.io/docs/learn — Sensors
Check yourself (from memory)
Q1. A sensor's job is to…
Q2. A sensor in "reschedule" mode…
Q3. To wait on another DAG's task, use…
ExternalTaskSensor waits for a specific
task/DAG in another DAG to complete.
ExternalTaskSensor needs
matching execution dates? Ask me.