Code RoomGraph node lock ordering
HardPrep Room Coding #2056

Graph node lock ordering

Code reviewConcurrencySenior–Staff~30 min

Review this Python graph engine. Each node has its own lock; an edge update locks both endpoints.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 30 min
Mark a line and say what kind of problem it is.0 findings
1class Node:
2 def __init__(self, name):
3 self.name = name
4 self.lock = threading.Lock()
5 self.edges = {}
6 
7def add_edge(a: Node, b: Node, weight):
8 with a.lock:
9 with b.lock:
10 a.edges[b.name] = weight
11 b.edges[a.name] = weight
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.