(self)
| 22 | self.window = window |
| 23 | |
| 24 | def tick(self): |
| 25 | current_time = time.time() |
| 26 | self.timestamps.append(current_time) |
| 27 | self.remove_old_timestamps(current_time) |
| 28 | |
| 29 | def remove_old_timestamps(self, current_time): |
| 30 | while self.timestamps and current_time - self.timestamps[0] > self.window: |