# Sensor Task

> A task that waits for a file or a table. Then the rest go on.

**Field:** Data Engineering  
**Category:** Orchestration  
**Also known as:** Airflow Sensor, Dagster Sensor

## Think of it like

It is like a dog by the door. It sits and waits until the mail drops in.

## Definition

A sensor is a task that waits for something outside the pipeline to happen. It might wait for a file to land, a table to fill or another job to end. It checks again and again, at a set gap. When the thing happens, the sensor succeeds and the next tasks start. If it waits too long, it times out and fails.

## Example

A partner drops a file on a server some time between 1 and 4 am. A sensor waits for it, and only then does the load start.

## Example code

```python
wait = S3KeySensor(
    task_id="wait_for_file",
    bucket_name="partner-drop",
    bucket_key="orders/{{ ds }}.csv",
    poke_interval=300,
    timeout=6 * 60 * 60,
    mode="reschedule",
)
```

An Airflow sensor that checks every 5 minutes for the day's file. It gives up after 6 hours.

## Why it matters

Other teams rarely deliver on a fixed clock. A sensor starts the work when the data is really there, not when you guessed it would be.

## Common mistake

Leaving out the timeout. A sensor that waits forever can hold a worker slot all day.

## Three principles

- **Wait for a sign.** A file, a row or a finished job.
- **Check on a gap.** It looks again every few minutes.
- **Time out.** It fails if the sign never comes.

## Related terms

- [Task Dependency](https://learn.benibix.com/term/data/task-dependency)
- [Data-Aware Scheduling](https://learn.benibix.com/term/data/data-aware-scheduling)
- [Workflow Orchestration](https://learn.benibix.com/term/data/workflow-orchestration)
- [Airflow Operator](https://learn.benibix.com/term/data/airflow-operator)
- [Airflow Provider Package](https://learn.benibix.com/term/data/airflow-provider-package)

![Three ways a run starts, side by side: a clock at 06:00, a sensor that checks every 5 minutes until a file appears, and an upstream table that, once updated, starts the downstream pipeline.](https://learn.benibix.com/diagrams/schedule-triggers.svg)

---

Source: https://learn.benibix.com/term/data/sensor-task
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
