Skip to content

Commit

Permalink
Ensure STT exceptions are being propagated
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzhao committed Dec 24, 2024
1 parent 37bbfcc commit b7924a7
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ async def recv_task(ws: aiohttp.ClientWebSocketResponse):
return

# this will trigger a reconnection, see the _run loop
raise Exception("deepgram connection closed unexpectedly")
raise APIStatusError("deepgram connection closed unexpectedly")

if msg.type != aiohttp.WSMsgType.TEXT:
logger.warning("unexpected deepgram message type %s", msg.type)
Expand All @@ -498,6 +498,14 @@ async def recv_task(ws: aiohttp.ClientWebSocketResponse):
[asyncio.gather(*tasks), wait_reconnect_task],
return_when=asyncio.FIRST_COMPLETED,
) # type: ignore

# need to propagate exceptions from completed tasks
for task in done:
if task != wait_reconnect_task:
exc = task.exception()
if exc is not None:
raise exc

if wait_reconnect_task not in done:
break

Expand Down

0 comments on commit b7924a7

Please sign in to comment.