Code Room
Code reviewMedium
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.
Learn the concepts
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() raiseRun or narrate your approach, then ask the coach.