diff --git a/apps/api/app/tasks/lipsync_tts.py b/apps/api/app/tasks/lipsync_tts.py index 7651911f5..187e0be07 100644 --- a/apps/api/app/tasks/lipsync_tts.py +++ b/apps/api/app/tasks/lipsync_tts.py @@ -269,7 +269,7 @@ def tts_synthesize_and_submit( retries = getattr(self.request, "retries", 0) max_retries = 3 if retries < max_retries: - backoff = (2 ** retries) + (retries * 1) # 1s, 3s, 7s + backoff = (2**retries) + (retries * 1) # 1s, 3s, 7s logger.warning( "[lipsync_tts] Job not found yet (retry %d/%d, backoff %ds): job_id=%s", retries + 1, diff --git a/tests/unit/test_lipsync_speed_optimization.py b/tests/unit/test_lipsync_speed_optimization.py index 13d9e4220..bca1c14dc 100644 --- a/tests/unit/test_lipsync_speed_optimization.py +++ b/tests/unit/test_lipsync_speed_optimization.py @@ -300,6 +300,7 @@ class TestCreateJobCommitOrder: def track_commit(): call_order.append("commit") + def track_apply_async(*args, **kwargs): call_order.append("apply_async") @@ -317,15 +318,17 @@ class TestCreateJobCommitOrder: # 至少有一次 commit 在 apply_async 之前 assert "commit" in call_order, "db.commit 必须被调用" assert "apply_async" in call_order, "apply_async 必须被调用" - assert call_order.index("commit") < call_order.index("apply_async"), ( - f"事务顺序错误:commit 必须在 apply_async 之前,实际顺序 {call_order}" - ) + assert call_order.index("commit") < call_order.index( + "apply_async" + ), f"事务顺序错误:commit 必须在 apply_async 之前,实际顺序 {call_order}" def test_job_not_found_retry_mechanism_exists(self): """worker 侧 job not found 必须有重试机制(self.retry),而不是静默 return。""" import inspect + from app.tasks.lipsync_tts import tts_synthesize_and_submit + source = inspect.getsource(tts_synthesize_and_submit.run) - assert "self.retry" in source or "retry" in source, ( - "tts_synthesize_and_submit 在 job not found 时必须重试,防止静默失败" - ) + assert ( + "self.retry" in source or "retry" in source + ), "tts_synthesize_and_submit 在 job not found 时必须重试,防止静默失败"