OrbiSubs: retry once when a keep-alive connection is dropped (whisper and LLM)
whisper.cpp closes idle keep-alive connections after ~5 s and we post every ~6 s, so a request can land on a socket the server is closing (RemoteDisconnected on T13, 2026-11-16 22:58:59, no error on gpu02). Timeouts are not retried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+5
-4
@@ -18,7 +18,7 @@ import argparse, json, os, statistics, time
|
||||
|
||||
import requests
|
||||
|
||||
from orbisubs import escribir_atomico, log, partir_lineas, ts_vtt
|
||||
from orbisubs import escribir_atomico, log, partir_lineas, post_reintento, ts_vtt
|
||||
|
||||
SISTEMA = ("You translate live Chilean Spanish TV captions into natural, concise English. "
|
||||
"Keep proper names, place names and Chilean acronyms (e.g. Carabineros, PDI, SII, AFP, Fonasa) as they are. "
|
||||
@@ -42,9 +42,10 @@ class Traductor:
|
||||
t = time.time()
|
||||
self.error = None
|
||||
try:
|
||||
r = self.s.post(self.url, json={"model": self.modelo, "temperature": 0, "max_tokens": 160,
|
||||
"chat_template_kwargs": {"enable_thinking": False},
|
||||
"messages": msgs}, timeout=self.timeout)
|
||||
# Mismo keep-alive que con whisper: un corte de conexión se reintenta una vez.
|
||||
r = post_reintento(self.s, self.url, json={"model": self.modelo, "temperature": 0, "max_tokens": 160,
|
||||
"chat_template_kwargs": {"enable_thinking": False},
|
||||
"messages": msgs}, timeout=self.timeout)
|
||||
r.raise_for_status()
|
||||
en = r.json()["choices"][0]["message"]["content"].strip().strip('"').strip()
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user