判断是否需要重试,返回日志提示内容
(self, error_str: str)
| 4098 | ) |
| 4099 | |
| 4100 | def _get_retry_reason(self, error_str: str) -> Optional[str]: |
| 4101 | """判断是否需要重试,返回日志提示内容""" |
| 4102 | error_lower = error_str.lower() |
| 4103 | if "error_no_slot_available_block" in error_lower: |
| 4104 | return "打码服务资源阻塞" |
| 4105 | if "error_no_slot_available" in error_lower: |
| 4106 | return "打码服务资源不足" |
| 4107 | if "403" in error_lower: |
| 4108 | return "403错误" |
| 4109 | if "429" in error_lower or "too many requests" in error_lower: |
| 4110 | return "429限流" |
| 4111 | if self._is_retryable_network_error(error_str): |
| 4112 | return "网络/TLS错误" |
| 4113 | if "recaptcha evaluation failed" in error_lower: |
| 4114 | return "reCAPTCHA 验证失败" |
| 4115 | if "recaptcha" in error_lower: |
| 4116 | return "reCAPTCHA 错误" |
| 4117 | if any(keyword in error_lower for keyword in [ |
| 4118 | "http error 500", |
| 4119 | "public_error", |
| 4120 | "internal error", |
| 4121 | "reason=internal", |
| 4122 | "reason: internal", |
| 4123 | "\"reason\":\"internal\"", |
| 4124 | "server error", |
| 4125 | "upstream error", |
| 4126 | ]): |
| 4127 | return "500/内部错误" |
| 4128 | return None |
| 4129 | |
| 4130 | def _get_retry_delay_seconds(self, error_str: str, retry_attempt: int) -> int: |
| 4131 | error_lower = str(error_str or "").lower() |
no test coverage detected