Skip to content

Commit

Permalink
Merge pull request #279 from Bycelium/bugfix/prevent-crash-on-cycle
Browse files Browse the repository at this point in the history
🪲 Prevent crash when there is a loop
  • Loading branch information
MathisFederico authored Feb 18, 2022
2 parents 59af190 + b8741fb commit 9634b5d
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 9634b5d

Please sign in to comment.