handle errors
This commit is contained in:
@@ -159,6 +159,7 @@ def generate_video(prompt):
|
||||
ws_url = f"ws://{COMFY_HOST}:{COMFY_PORT}/ws?clientId={ws_client_id}"
|
||||
|
||||
ws = ws_client.WebSocket()
|
||||
try:
|
||||
ws.connect(ws_url)
|
||||
logger.info("🔌 WebSocket подключён к ComfyUI")
|
||||
|
||||
@@ -167,7 +168,17 @@ def generate_video(prompt):
|
||||
|
||||
# Ждём завершения
|
||||
while True:
|
||||
try:
|
||||
out = ws.recv()
|
||||
except ws_client.WebSocketConnectionClosedException:
|
||||
# ComfyUI разорвал соединение — проверяем что случилось
|
||||
logger.error(f"⚠️ ComfyUI закрыл WebSocket для prompt {prompt_id}")
|
||||
raise RuntimeError(
|
||||
"ComfyUI connection lost during generation. "
|
||||
"Possible causes: Out of VRAM, workflow error, or ComfyUI crash. "
|
||||
"Check ComfyUI logs: journalctl -u comfyui -n 100"
|
||||
)
|
||||
|
||||
if isinstance(out, str):
|
||||
message = json.loads(out)
|
||||
if message["type"] == "executing":
|
||||
@@ -177,6 +188,12 @@ def generate_video(prompt):
|
||||
|
||||
ws.close()
|
||||
logger.info("✅ Генерация завершена")
|
||||
except Exception as e:
|
||||
try:
|
||||
ws.close()
|
||||
except:
|
||||
pass
|
||||
raise
|
||||
|
||||
# Извлекаем видео
|
||||
history = get_history(prompt_id)[prompt_id]
|
||||
|
||||
Reference in New Issue
Block a user