Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix event chain bg update. #9118

Merged
merged 2 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/9118.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve efficiency of large state resolutions.
2 changes: 1 addition & 1 deletion synapse/util/iterutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def sorted_topologically(
node = heapq.heappop(zero_degree)
yield node

for edge in reverse_graph[node]:
for edge in reverse_graph.get(node, []):
if edge in degree_map:
degree_map[edge] -= 1
if degree_map[edge] == 0:
Expand Down
8 changes: 8 additions & 0 deletions tests/util/test_itertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ def test_empty(self):
graph = {} # type: Dict[int, List[int]]
self.assertEqual(list(sorted_topologically([], graph)), [])

def test_handle_empty_graph(self):
"Test that a graph where a node doesn't have an entry is treated as empty"

graph = {} # type: Dict[int, List[int]]

# For disconnected nodes the output is simply sorted.
self.assertEqual(list(sorted_topologically([1, 2], graph)), [1, 2])

def test_disconnected(self):
"Test that a graph with no edges work"

Expand Down