dstandish commented on code in PR #32538:
URL: https://github.com/apache/airflow/pull/32538#discussion_r1262910810


##########
airflow/operators/python.py:
##########
@@ -251,27 +253,37 @@ def execute(self, context: Context) -> Any:
             self.log.info("Proceeding with downstream tasks...")
             return condition
 
-        downstream_tasks = context["task"].get_flat_relatives(upstream=False)
-        self.log.debug("Downstream task IDs %s", downstream_tasks)
+        if not self.downstream_task_ids:
+            self.log.info("No downstream tasks; nothing to do.")
+            return
 
-        if downstream_tasks:
-            dag_run = context["dag_run"]
-            execution_date = dag_run.execution_date
+        dag_run = context["dag_run"]
+        execution_date = dag_run.execution_date
+        if TYPE_CHECKING:
+            assert isinstance(execution_date, DateTime)
 
+        def get_tasks_to_skip():
             if self.ignore_downstream_trigger_rules is True:
-                self.log.info("Skipping all downstream tasks...")
-                self.skip(dag_run, execution_date, downstream_tasks, 
map_index=context["ti"].map_index)
+                tasks = context["task"].get_flat_relatives(upstream=False)
             else:
-                self.log.info("Skipping downstream tasks while respecting 
trigger rules...")
-                # Explicitly setting the state of the direct, downstream 
task(s) to "skipped" and letting the
-                # Scheduler handle the remaining downstream task(s) 
appropriately.
-                self.skip(
-                    dag_run,
-                    execution_date,
-                    context["task"].get_direct_relatives(upstream=False),
-                    map_index=context["ti"].map_index,
-                )
-
+                tasks = context["task"].get_direct_relatives(upstream=False)
+            for t in tasks:
+                if not t.is_teardown:
+                    yield t
+
+        to_skip = get_tasks_to_skip()
+
+        # this let's us avoid an intermediate list unless debug logging
+        if self.log.getEffectiveLevel() <= logging.DEBUG:
+            self.log.debug("Downstream task IDs %s", to_skip := 
list(get_tasks_to_skip()))

Review Comment:
   > Ah OK get_tasks_to_skip() is an iterator. Maybe move the line to below 
this block instead then?
   
   don't follow -- what would that do?



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