Adding retries
You've noticed that one particular Dag is failing often on a task that extracts data from a given source. Frustratingly, running the task a few minutes later seems to remedy the problem. After learning about the retry functionality in Airflow Dags, you decide to implement retries on this task to keep from restarting it manually.
The dag, task, and timedelta are already imported for you.
Diese Übung ist Teil des Kurses
Einführung in Apache Airflow mit Python
Anleitung zur Übung
- Set the
extract_datatask to retry 3 times before failing. - Add a delay of 10 minutes between retries on the
extract_datatask.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
@dag(schedule="@daily", start_date=datetime(2026, 5, 1))
def etl_pipeline():
# Set retries and retry delay on extract_data
@task(____=3, ____=____(minutes=10))
def extract_data():
print("Extracting data from source...")
@task()
def process_source_data():
print("Now processing data...")
extract_data() >> process_source_data()
etl_pipeline()