handle client disconnects in SSE and streaming endpoints

Wrap SSE generators with BrokenPipeError/ConnectionResetError handling
so client disconnects during generation status polling, download progress,
or audio streaming don't produce unhandled Errno 32 errors.

Closes #248
This commit is contained in:
Jamie Pine
2026-03-16 23:17:09 -07:00
parent 01800f196f
commit f9e1aa153d
2 changed files with 30 additions and 19 deletions
+2
View File
@@ -246,6 +246,8 @@ class ProgressManager:
# Send heartbeat
yield ": heartbeat\n\n"
continue
except (BrokenPipeError, ConnectionResetError, asyncio.CancelledError):
logger.debug(f"SSE client disconnected from {model_name}")
finally:
# Remove from listeners
if model_name in self._listeners: