(self)
| 58 | self.lock = asyncio.Lock() |
| 59 | |
| 60 | async def acquire(self) -> bool: |
| 61 | async with self.lock: |
| 62 | now = time.monotonic() |
| 63 | elapsed = now - self.last_refill |
| 64 | self.tokens = min(self.capacity, self.tokens + elapsed * self.refill_rate) |
| 65 | self.last_refill = now |
| 66 | self.last_accessed = now |
| 67 | if self.tokens >= 1: |
| 68 | self.tokens -= 1 |
| 69 | return True |
| 70 | return False |
| 71 | |
| 72 | |
| 73 | class _RateLimiterRegistry: |
no outgoing calls
no test coverage detected