sunank200 commented on code in PR #40084:
URL: https://github.com/apache/airflow/pull/40084#discussion_r1684595916
##########
docs/apache-airflow/authoring-and-scheduling/deferring.rst:
##########
@@ -213,6 +213,70 @@ This is particularly useful when deferring is the only
thing the ``execute`` met
# We have no more work to do here. Mark as complete.
return
+Exiting deferred task from Triggers
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ .. versionadded:: 2.10.0
+
+If you want to exit your task directly from the triggerer without going into
the worker, you can specific operator level attribute ``end_from_trigger`` with
the attributes to your deferrable operator other discussed above.
+
+Triggers can have two options: they can either send execution back to the
worker or end the task instance directly. If the trigger ends the task instance
itself, the ``method_name`` does not matter and can be ``None``. Otherwise,
provide the name of the ``method_name`` that should be used when resuming
execution in the task.
+
+.. code-block:: python
+
+ class DateTimeSensorAsync(DateTimeSensor):
+ def __init__(self, end_from_trigger: bool = True, **kwargs) -> None:
+ super().__init__(**kwargs)
+ self.end_from_trigger = end_from_trigger
+
+ def execute(self, context: Context) -> NoReturn:
+ self.defer(
+ method_name="execute_complete",
Review Comment:
It can be anything and it doesn't matter actually.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]