Content-Length: 291742 | pFad | http://github.com/apache/airflow/commit/b92f6198d1944b0ae5e0b6ebc928f7cd3bdf39b0

65 Rewrite recursion when parsing DAG into iteration (#25898) · apache/airflow@b92f619 · GitHub
Skip to content

Commit b92f619

Browse files
authored
Rewrite recursion when parsing DAG into iteration (#25898)
This avoids a RecursionError when parsing a DAG with very deep dependencies that takes the interpreter over `sys.getrecursionlimit()`
1 parent 63d38b8 commit b92f619

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

airflow/models/abstractoperator.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,18 @@ def get_flat_relative_ids(
214214
if not dag:
215215
return set()
216216

217-
if not found_descendants:
217+
if found_descendants is None:
218218
found_descendants = set()
219-
relative_ids = self.get_direct_relative_ids(upstream)
220219

221-
for relative_id in relative_ids:
222-
if relative_id not in found_descendants:
223-
found_descendants.add(relative_id)
224-
relative_task = dag.task_dict[relative_id]
225-
relative_task.get_flat_relative_ids(upstream, found_descendants)
220+
task_ids_to_trace = self.get_direct_relative_ids(upstream)
221+
while task_ids_to_trace:
222+
task_ids_to_trace_next: Set[str] = set()
223+
for task_id in task_ids_to_trace:
224+
if task_id in found_descendants:
225+
continue
226+
task_ids_to_trace_next.update(dag.task_dict[task_id].get_direct_relative_ids(upstream))
227+
found_descendants.add(task_id)
228+
task_ids_to_trace = task_ids_to_trace_next
226229

227230
return found_descendants
228231

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/apache/airflow/commit/b92f6198d1944b0ae5e0b6ebc928f7cd3bdf39b0

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy