uranusjr commented on code in PR #41232:
URL: https://github.com/apache/airflow/pull/41232#discussion_r1716607556


##########
airflow/triggers/base.py:
##########
@@ -115,6 +116,19 @@ async def cleanup(self) -> None:
         and handle it appropriately (in async-compatible way).
         """
 
+    def should_cleanup(self, termination_reason: TriggerTerminationReason | 
None) -> bool:
+        """
+        Check the trigger should be cleaned up or not base on the context.
+
+        :param termination_reason: The reason for terminating the trigger.
+        Since the trigger could be terminated for various reasons, like 
triggerer restart or reassigned to
+        another triggerer, this method allows the trigger to decide whether it 
should be cleaned up under the
+        current circumstances.
+
+        By default, will always return True, override this method base custom 
requirements.

Review Comment:
   Some text should also be added to the documentation (probably in the 
*Deferrable Operators & Triggers* page?) to teach users when/how this can be 
used.



-- 
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]

Reply via email to