Code Room
Code reviewHard
Question
Review this Python parallel tree-aggregator using a thread pool.
Under a deep/wide tree this hangs. What is the concurrency bug?
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.
Learn the concepts
from concurrent.futures import ThreadPoolExecutor pool = ThreadPoolExecutor(max_workers=4) def aggregate(node): if node.is_leaf: return node.value # fan each child out to the pool, then block on the results futures = [pool.submit(aggregate, c) for c in node.children] # (1) return sum(f.result() for f in futures) # (2)Run or narrate your approach, then ask the coach.