Limiter non-atomic read-modify-write
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.
0:00 of about 24 min
Mark a line and say what kind of problem it is.0 findings
1class Limiter:
2 def __init__(self):
3 self.counts = {}
4
5 def allow(self, key, limit):
6 n = self.counts.get(key, 0)
7 if n >= limit:
8 return False
9 self.counts[key] = n + 1
10 return True
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.