Record token error and auto-disable if threshold reached
(self, token_id: int)
| 960 | await self.db.increment_token_stats(token_id, "image") |
| 961 | |
| 962 | async def record_error(self, token_id: int): |
| 963 | """Record token error and auto-disable if threshold reached""" |
| 964 | await self.db.increment_token_stats(token_id, "error") |
| 965 | |
| 966 | # Check if should auto-disable token (based on consecutive errors) |
| 967 | stats = await self.db.get_token_stats(token_id) |
| 968 | admin_config = await self.db.get_admin_config() |
| 969 | |
| 970 | if stats and stats.consecutive_error_count >= admin_config.error_ban_threshold: |
| 971 | debug_logger.log_warning( |
| 972 | f"[TOKEN_BAN] Token {token_id} consecutive error count ({stats.consecutive_error_count}) " |
| 973 | f"reached threshold ({admin_config.error_ban_threshold}), auto-disabling" |
| 974 | ) |
| 975 | await self.disable_token(token_id) |
| 976 | |
| 977 | async def record_success(self, token_id: int): |
| 978 | """Record successful request (reset consecutive error count) |
no test coverage detected