Spaces:
Paused
Paused
Malina Claude Sonnet 4.6 commited on
Commit ·
3e1b026
1
Parent(s): 8aa6bb8
NINA: SSE keepalive for mobile — prevent stuck 'Uploading & analyzing'
Browse filesRun ingest_video() in a background thread and yield '⏳ …' every 15 s
while waiting. Mobile SSE connections (iOS Safari, carrier proxies) time
out after ~60 s of silence; the 1-5 min transcription+CLIP phase was
completely silent, permanently hanging mobile clients. Keepalives keep
the connection alive without any visible UX change (client silences them).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- pipeline.py +19 -1
pipeline.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import time
|
| 2 |
from concurrent.futures import ThreadPoolExecutor
|
| 3 |
|
|
@@ -121,7 +122,24 @@ def run(video_path: str, prompt: str, token: str = ""):
|
|
| 121 |
_cache[video_path] = entry
|
| 122 |
else:
|
| 123 |
yield "🎬 Reading video — transcribing audio and scanning frames…"
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
if not entry["segments"]:
|
| 126 |
yield "No speech detected."
|
| 127 |
return
|
|
|
|
| 1 |
+
import threading
|
| 2 |
import time
|
| 3 |
from concurrent.futures import ThreadPoolExecutor
|
| 4 |
|
|
|
|
| 122 |
_cache[video_path] = entry
|
| 123 |
else:
|
| 124 |
yield "🎬 Reading video — transcribing audio and scanning frames…"
|
| 125 |
+
# Run ingestion in a background thread so we can yield keepalives every
|
| 126 |
+
# 15 s — mobile SSE connections (iOS Safari, carrier proxies) time out
|
| 127 |
+
# after ~60 s of silence, which is shorter than ingest can take.
|
| 128 |
+
_res: dict = {}
|
| 129 |
+
_evt = threading.Event()
|
| 130 |
+
def _do_ingest():
|
| 131 |
+
try:
|
| 132 |
+
_res["v"] = ingest_video(video_path)
|
| 133 |
+
except Exception as e:
|
| 134 |
+
_res["err"] = e
|
| 135 |
+
_evt.set()
|
| 136 |
+
threading.Thread(target=_do_ingest, daemon=True).start()
|
| 137 |
+
while not _evt.wait(15.0):
|
| 138 |
+
yield "⏳ …" # keepalive — client silences this; SSE stays alive
|
| 139 |
+
if "err" in _res:
|
| 140 |
+
yield "Error reading video."
|
| 141 |
+
return
|
| 142 |
+
entry = _res["v"]
|
| 143 |
if not entry["segments"]:
|
| 144 |
yield "No speech detected."
|
| 145 |
return
|