celery 容灾升级

This commit is contained in:
2026-07-22 14:48:29 +08:00
parent 3f1c4063b0
commit 69e7dec807
67 changed files with 6161 additions and 1958 deletions
@@ -3,7 +3,7 @@ from __future__ import annotations
import json
from dataclasses import dataclass
from types import SimpleNamespace
from typing import Any
from typing import Any, Awaitable, Callable
from fastapi import HTTPException
from sqlalchemy import select
@@ -730,6 +730,7 @@ async def run_video_prompt_optimize_v2(
*,
project_id: str,
step_id: str,
execution_guard: Callable[[], Awaitable[None]] | None = None,
) -> ModuleGenerationStep | None:
try:
meta_result = await execute_with_lock_timeout(
@@ -800,6 +801,8 @@ async def run_video_prompt_optimize_v2(
step_id=project_snapshot["step_id"],
)
if execution_guard is not None:
await execution_guard()
locked = await execute_with_lock_timeout(
db,
select(ModuleGenerationProject, ModuleGenerationStep)
@@ -885,6 +888,8 @@ async def run_video_prompt_optimize_v2(
except Exception as exc:
await db.rollback()
try:
if execution_guard is not None:
await execution_guard()
result = await execute_with_lock_timeout(
db,
select(ModuleGenerationProject, ModuleGenerationStep)