BaşlayınÜcretsiz Başlayın

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.

Bu egzersiz

Python ile Apache Airflow'a Giriş

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Set the extract_data task to retry 3 times before failing.
  • Add a delay of 10 minutes between retries on the extract_data task.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

@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()
Kodu Düzenle ve Çalıştır