| Conditions | 6 |
| Total Lines | 16 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | |||
| 20 | def filter(self, record: LogRecord) -> bool: |
||
| 21 | key = self._record_key(record) |
||
| 22 | current_time = time.time() |
||
| 23 | with self._lock: |
||
| 24 | if key not in self._cache: |
||
| 25 | self._cache[key] = current_time |
||
| 26 | if len(self._cache) > self.cache_size: |
||
| 27 | self._cache.popitem(last=False) |
||
| 28 | return True |
||
| 29 | elif current_time - self._cache[key] > self.lockout_time: |
||
| 30 | self._cache[key] = current_time |
||
| 31 | self._cache.move_to_end(key) |
||
| 32 | if len(self._cache) > self.cache_size: |
||
| 33 | self._cache.popitem(last=False) |
||
| 34 | return True |
||
| 35 | return False |
||
| 36 | |||
| 47 |