Skip to content

Commit 2ca6dbd

Browse files
committed
fix: handle socket connection closed error in _signal_exit
1 parent d2c4334 commit 2ca6dbd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

deepgram/clients/live/v1/async_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,11 @@ async def _signal_exit(self) -> None:
485485
self.logger.verbose("closing socket...")
486486
if self._socket is not None:
487487
self.logger.verbose("send CloseStream...")
488-
await self._socket.send(json.dumps({"type": "CloseStream"}))
488+
try:
489+
# if the socket connection is closed, the following line might throw an error
490+
await self._socket.send(json.dumps({"type": "CloseStream"}))
491+
except Exception as e:
492+
self.logger.error("Exception in AsyncLiveClient._signal_exit, %s", e)
489493

490494
await asyncio.sleep(0.5)
491495

0 commit comments

Comments
 (0)