Code Room
Code reviewMediumcr-g313
Subject Circuit breakerLevel Mid–Senior~18 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Python breaker that guards a downstream and counts failures to decide when to open.

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.

Talk through your review
Code to reviewpython
def call(self, fn, *args):    if self.open and time.time() - self.opened_at < self.cooldown:        raise CircuitOpen()    try:        return fn(*args)    except Exception:        self.failures += 1        if self.failures >= self.threshold:            self.open = True            self.opened_at = time.time()        raise
Run or narrate your approach, then ask the coach.