Skip to content

Commit

Permalink
🪲 Prevent crash when there is a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
FabienRoger committed Feb 17, 2022
1 parent 584b84c commit b8741fb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pyflow/blocks/executableblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,18 @@ def custom_bfs(self, start_node, reverse=False):
to_transmit: List[List[Union["ExecutableBlock", "Edge"]]] = [[start_node]]

to_visit: List["ExecutableBlock"] = [start_node]

# Set to make sure to never execute the same block twice
visited: Set["ExecutableBlock"] = set([])

while to_visit:
# Remove duplicates
to_visit = list(set(to_visit))
to_visit_set = set(to_visit)
to_visit_set.difference_update(visited)
to_visit = list(to_visit_set)

# Update the visited block set
visited.update(to_visit_set)

# Gather connected edges
edges_to_visit = []
Expand Down

0 comments on commit b8741fb

Please sign in to comment.