--- solution.py +++ solution.py (mutant) @@ -14,15 +14 @@ self._tokens = float(capacity) - self._last = time.monotonic() - self._lock = threading.Lock() - - def consume(self, tokens=1.0): - """Try to consume tokens; return True on success.""" - with self._lock: - now = time.monotonic() - self._tokens = min(self._capacity, - self._tokens + (now - self._last) * self._rate) - self._last = now - if tokens <= self._tokens: - self._tokens -= tokens - return True - return False