You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ep...@apache.org on 2022/06/29 15:20:26 UTC
[airflow] 41/45: Add imports to deferring code samples (#24544)
This is an automated email from the ASF dual-hosted git repository.
ephraimanierobi pushed a commit to branch v2-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 2320145803b82a42039f90d8761b22a137ee64f3
Author: Bas Harenslak <Ba...@users.noreply.github.com>
AuthorDate: Sun Jun 19 10:53:15 2022 +0200
Add imports to deferring code samples (#24544)
(cherry picked from commit cabbf616bbc3139b1ce793c9daa20f13c82eb287)
---
docs/apache-airflow/concepts/deferring.rst | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/docs/apache-airflow/concepts/deferring.rst b/docs/apache-airflow/concepts/deferring.rst
index ca810d7972..3b5bf1b72d 100644
--- a/docs/apache-airflow/concepts/deferring.rst
+++ b/docs/apache-airflow/concepts/deferring.rst
@@ -82,6 +82,12 @@ You are free to set ``method_name`` to ``execute`` if you want your Operator to
Here's a basic example of how a sensor might trigger deferral::
+ from datetime import timedelta
+
+ from airflow.sensors.base import BaseSensorOperator
+ from airflow.triggers.temporal import TimeDeltaTrigger
+
+
class WaitOneHourSensor(BaseSensorOperator):
def execute(self, context):
self.defer(trigger=TimeDeltaTrigger(timedelta(hours=1)), method_name="execute_complete")
@@ -122,6 +128,12 @@ There's also some design constraints to be aware of:
Here's the structure of a basic Trigger::
+ import asyncio
+
+ from airflow.triggers.base import BaseTrigger, TriggerEvent
+ from airflow.utils import timezone
+
+
class DateTimeTrigger(BaseTrigger):
def __init__(self, moment):