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:
+21
-2
@@ -106,6 +106,25 @@ class MotorLocal:
|
||||
return [(w.start, w.end, w.word) for s in segs for w in (s.words or [])]
|
||||
|
||||
|
||||
def post_reintento(sesion, url, **kw):
|
||||
"""POST con un solo reintento si se cortó la conexión.
|
||||
|
||||
Caso real (T13, 2026-11-16 22:58:59): RemoteDisconnected en un pedido a whisper.cpp,
|
||||
sin ningún error en gpu02. Mandamos un pedido cada ~6 s por una conexión keep-alive y
|
||||
el server (cpp-httplib) cierra las inactivas a los ~5 s. Si el pedido sale justo
|
||||
cuando el server cierra, llega a un socket muerto. Reintentar abre una conexión nueva.
|
||||
Es seguro: /inference y chat/completions no cambian estado en el server.
|
||||
Un timeout NO se reintenta: ahí el motor está lento y repetir lo carga más."""
|
||||
import requests
|
||||
try:
|
||||
return sesion.post(url, **kw)
|
||||
except requests.exceptions.ConnectionError as e:
|
||||
if isinstance(e, requests.exceptions.Timeout):
|
||||
raise
|
||||
log("http_retry", url=url, err=str(e)[:200])
|
||||
return sesion.post(url, **kw)
|
||||
|
||||
|
||||
class MotorHTTP:
|
||||
"""whisper.cpp server remoto (gpu02, tarea 076-agregado): solo POST /inference,
|
||||
un pedido a la vez (este proceso es secuencial). Nunca /load: cambia el modelo
|
||||
@@ -129,8 +148,8 @@ class MotorHTTP:
|
||||
data["prompt"] = prompt
|
||||
t = time.time()
|
||||
try:
|
||||
r = self.s.post(self.url, files={"file": ("a.wav", b.getvalue(), "audio/wav")}, data=data,
|
||||
timeout=self.timeout)
|
||||
r = post_reintento(self.s, self.url, files={"file": ("a.wav", b.getvalue(), "audio/wav")},
|
||||
data=data, timeout=self.timeout)
|
||||
r.raise_for_status()
|
||||
d = r.json()
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user