feat: 新增登录态过期不重试逻辑,优化社保核对流程
1. 重构重试装饰器,新增no_retry_on参数支持指定异常不重试 2. 为社保核对模块添加登录态过期检测与自动刷新逻辑 3. 统一两处社保业务代码的异常处理与会话重建流程 4. 更新版本号与默认输出目录配置
This commit is contained in:
@@ -23,12 +23,13 @@ class RetryExhaustedError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def retry(max_attempts: int = 3) -> Callable:
|
||||
def retry(max_attempts: int = 3, no_retry_on: tuple = ()) -> Callable:
|
||||
"""
|
||||
重试装饰器:内置指数退避 + 随机抖动,只暴露重试次数。
|
||||
|
||||
Args:
|
||||
max_attempts: 最大尝试次数(含首次执行),默认 3,必须 >= 1。
|
||||
no_retry_on: 遇到这些异常类型时直接抛出、不做重试(用于无需重试的确定性失败)。
|
||||
|
||||
内部行为(对调用方透明):
|
||||
- 捕获所有 Exception;
|
||||
@@ -48,6 +49,8 @@ def retry(max_attempts: int = 3) -> Callable:
|
||||
for attempt in range(1, max_attempts + 1):
|
||||
try:
|
||||
return func(*args, **kwargs)
|
||||
except no_retry_on:
|
||||
raise
|
||||
except Exception as e:
|
||||
last_exc = e
|
||||
if attempt >= max_attempts:
|
||||
|
||||
Reference in New Issue
Block a user