This is an automated email from the ASF dual-hosted git repository.
ferruzzi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 553c41633ed Fix Deadline Alert SmtpNotifier example in Dag docs
(#75597)
553c41633ed is described below
commit 553c41633ed40ac93982af55ebadf5071f45f5bc
Author: LiaoAB <[email protected]>
AuthorDate: Sat Nov 7 06:05:21 2026 +0800
Fix Deadline Alert SmtpNotifier example in Dag docs (#75597)
---
airflow-core/docs/core-concepts/dags.rst | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/airflow-core/docs/core-concepts/dags.rst
b/airflow-core/docs/core-concepts/dags.rst
index 9946e17bb72..d4822c2c39b 100644
--- a/airflow-core/docs/core-concepts/dags.rst
+++ b/airflow-core/docs/core-concepts/dags.rst
@@ -947,24 +947,33 @@ thresholds are exceeded. You can set deadlines relative
to a fixed datetime, use
calculated references (like Dag queue time or start time), or implement your
own custom reference.
When a deadline is exceeded, it triggers a callback which can notify you or
take other actions.
-Here's a simple example using the existing email Notifier:
+Here's a simple example using the existing email Notifier. A Notifier cannot
be passed as the
+``callback`` directly: wrap it in a :class:`~airflow.sdk.AsyncCallback` (or
+:class:`~airflow.sdk.SyncCallback`) and pass the Notifier arguments through
``kwargs``:
.. code-block:: python
from datetime import timedelta
- from airflow.sdk import DAG
+
from airflow.providers.smtp.notifications.smtp import SmtpNotifier
- from airflow.sdk.definitions.deadline import DeadlineAlert,
DeadlineReference
+ from airflow.providers.standard.operators.empty import EmptyOperator
+ from airflow.sdk import AsyncCallback, DAG, DeadlineAlert,
DeadlineReference
with DAG(
dag_id="email_deadline",
deadline=DeadlineAlert(
reference=DeadlineReference.DAGRUN_QUEUED_AT,
interval=timedelta(minutes=30),
- callback=SmtpNotifier(
- to="[email protected]",
- subject="🚨 Dag {{ dag_run.dag_id }} missed deadline at {{
deadline.deadline_time }}",
- html_content="The Dag Run {{ dag_run.dag_run_id }} has been
running for more than 30 minutes since being queued.",
+ callback=AsyncCallback(
+ SmtpNotifier,
+ kwargs={
+ "to": "[email protected]",
+ "subject": "🚨 Dag {{ dag_run.dag_id }} missed deadline at
{{ deadline.deadline_time }}",
+ "html_content": (
+ "The Dag Run {{ dag_run.dag_run_id }} has been running
for more than 30 minutes "
+ "since being queued."
+ ),
+ },
),
),
):