Code Room
Code reviewMediumcr-g429
Subject Thread safetyLevel Mid–Senior~24 minCommon in Concurrency interviewsIndustries Software development

Question

Review this Python in-memory rate counter shared across request threads (CPython, with the GIL).

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
class Limiter:    def __init__(self):        self.counts = {}     def allow(self, key, limit):        n = self.counts.get(key, 0)        if n >= limit:            return False        self.counts[key] = n + 1        return True
Run or narrate your approach, then ask the coach.