mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix(realtime): remove empty exception handlers
This commit is contained in:
parent
e0726859ef
commit
16a19f16c2
2 changed files with 7 additions and 5 deletions
|
|
@ -230,12 +230,14 @@ MAX_REALTIME_OFFER_BYTES: Final = 8 * 1024 * 1024
|
|||
|
||||
|
||||
async def _cache_bounded_offer_body(request: Request) -> None:
|
||||
content_length: int | None
|
||||
try:
|
||||
if int(request.headers.get("content-length", "")) > MAX_REALTIME_OFFER_BYTES:
|
||||
raise HTTPException(413, "Realtime offer exceeds the 8 MiB limit")
|
||||
content_length = int(request.headers.get("content-length", ""))
|
||||
except ValueError:
|
||||
# A missing or non-numeric content length is checked while streaming below.
|
||||
pass
|
||||
content_length = None
|
||||
if content_length is not None and content_length > MAX_REALTIME_OFFER_BYTES:
|
||||
raise HTTPException(413, "Realtime offer exceeds the 8 MiB limit")
|
||||
if hasattr(request, "_body"):
|
||||
if len(request._body) > MAX_REALTIME_OFFER_BYTES: # pyright: ignore[reportPrivateUsage] # validate Starlette's cached body without consuming it again
|
||||
raise HTTPException(413, "Realtime offer exceeds the 8 MiB limit")
|
||||
|
|
|
|||
|
|
@ -1522,13 +1522,13 @@ async def websocket_live_session(websocket: WebSocket, session_id: str | None =
|
|||
await websocket.close(code=1008, reason="Live session rejected")
|
||||
except RuntimeError:
|
||||
# The peer may have closed the socket before the rejection response.
|
||||
pass
|
||||
return
|
||||
except Exception:
|
||||
try:
|
||||
await websocket.close(code=1011, reason="Live upstream connection failed")
|
||||
except RuntimeError:
|
||||
# The peer may have closed the socket before the failure response.
|
||||
pass
|
||||
return
|
||||
finally:
|
||||
if state.connection is not None:
|
||||
await state.connection.close()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue