File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
deepgram/clients/common/v1 Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -254,12 +254,18 @@ async def _listening(self) -> None:
254254 self ._logger .debug ("AbstractAsyncWebSocketClient._listening LEAVE" )
255255
256256 except websockets .exceptions .ConnectionClosedOK as e :
257+ # signal exit and close
258+ await self ._signal_exit ()
259+
257260 self ._logger .notice (f"_listening({ e .code } ) exiting gracefully" )
258261 self ._logger .debug ("AbstractAsyncWebSocketClient._listening LEAVE" )
259262 return
260263
261264 except websockets .exceptions .ConnectionClosed as e :
262265 if e .code in [1000 , 1001 ]:
266+ # signal exit and close
267+ await self ._signal_exit ()
268+
263269 self ._logger .notice (f"_listening({ e .code } ) exiting gracefully" )
264270 self ._logger .debug ("AbstractAsyncWebSocketClient._listening LEAVE" )
265271 return
@@ -466,7 +472,7 @@ async def finish(self) -> bool:
466472 except asyncio .CancelledError as e :
467473 self ._logger .error ("tasks cancelled error: %s" , e )
468474 self ._logger .debug ("AbstractAsyncWebSocketClient.finish LEAVE" )
469- return False
475+ return True
470476
471477 async def _signal_exit (self ) -> None :
472478 # send close event
Original file line number Diff line number Diff line change @@ -256,12 +256,18 @@ def _listening(
256256 self ._logger .debug ("AbstractSyncWebSocketClient._listening LEAVE" )
257257
258258 except websockets .exceptions .ConnectionClosedOK as e :
259+ # signal exit and close
260+ self ._signal_exit ()
261+
259262 self ._logger .notice (f"_listening({ e .code } ) exiting gracefully" )
260263 self ._logger .debug ("AbstractSyncWebSocketClient._listening LEAVE" )
261264 return
262265
263266 except websockets .exceptions .ConnectionClosed as e :
264267 if e .code in [1000 , 1001 ]:
268+ # signal exit and close
269+ self ._signal_exit ()
270+
265271 self ._logger .notice (f"_listening({ e .code } ) exiting gracefully" )
266272 self ._logger .debug ("AbstractSyncWebSocketClient._listening LEAVE" )
267273 return
You can’t perform that action at this time.
0 commit comments