MCPcopy Create free account
hub / github.com/TheSmallHanCat/flow2api / record_error

Method record_error

src/services/token_manager.py:962–975  ·  view source on GitHub ↗

Record token error and auto-disable if threshold reached

(self, token_id: int)

Source from the content-addressed store, hash-verified

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)

Callers 1

handle_generationMethod · 0.80

Calls 5

disable_tokenMethod · 0.95
increment_token_statsMethod · 0.80
get_token_statsMethod · 0.80
get_admin_configMethod · 0.80
log_warningMethod · 0.80

Tested by

no test coverage detected