From cdf39ce565a3d3318c1ad0d2a02bece84d7a68a8 Mon Sep 17 00:00:00 2001 From: jkroll-deepgram Date: Tue, 16 Apr 2024 08:33:06 -0500 Subject: [PATCH 1/2] Check if _exit_event is None --- deepgram/clients/live/v1/async_client.py | 6 +++--- deepgram/clients/live/v1/client.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deepgram/clients/live/v1/async_client.py b/deepgram/clients/live/v1/async_client.py index 07bcbb1a..cfcd33b0 100644 --- a/deepgram/clients/live/v1/async_client.py +++ b/deepgram/clients/live/v1/async_client.py @@ -184,7 +184,7 @@ async def _listening(self) -> None: while True: try: - if self._exit_event.is_set(): + if self._exit_event is not None and self._exit_event.is_set(): self.logger.notice("_listening exiting gracefully") self.logger.debug("AsyncLiveClient._listening LEAVE") return @@ -336,7 +336,7 @@ async def _keep_alive(self) -> None: counter += 1 await asyncio.sleep(ONE_SECOND) - if self._exit_event.is_set(): + if self._exit_event is not None and self._exit_event.is_set():: self.logger.notice("_keep_alive exiting gracefully") self.logger.debug("AsyncLiveClient._keep_alive LEAVE") return @@ -409,7 +409,7 @@ async def send(self, data: Union[str, bytes]) -> bool: """ self.logger.spam("AsyncLiveClient.send ENTER") - if self._exit_event.is_set(): + if self._exit_event is not None and self._exit_event.is_set(): self.logger.notice("send exiting gracefully") self.logger.debug("AsyncLiveClient.send LEAVE") return False diff --git a/deepgram/clients/live/v1/client.py b/deepgram/clients/live/v1/client.py index 8cd425a5..ca5cf6fb 100644 --- a/deepgram/clients/live/v1/client.py +++ b/deepgram/clients/live/v1/client.py @@ -184,7 +184,7 @@ def _listening(self) -> None: while True: try: - if self._exit_event.is_set(): + if self._exit_event is not None and self._exit_event.is_set(): self.logger.notice("_listening exiting gracefully") self.logger.debug("LiveClient._listening LEAVE") return @@ -336,7 +336,7 @@ def _keep_alive(self) -> None: counter += 1 self._exit_event.wait(timeout=ONE_SECOND) - if self._exit_event.is_set(): + if self._exit_event is not None and self._exit_event.is_set(): self.logger.notice("_keep_alive exiting gracefully") self.logger.debug("LiveClient._keep_alive LEAVE") return @@ -407,7 +407,7 @@ def send(self, data: Union[str, bytes]) -> bool: """ self.logger.spam("LiveClient.send ENTER") - if self._exit_event.is_set(): + if self._exit_event is not None and self._exit_event.is_set(): self.logger.notice("send exiting gracefully") self.logger.debug("AsyncLiveClient.send LEAVE") return False From 201843f3216fbf27ab1a841b74ffd75d19f24767 Mon Sep 17 00:00:00 2001 From: jkroll-deepgram Date: Tue, 16 Apr 2024 08:43:52 -0500 Subject: [PATCH 2/2] Fix typo --- deepgram/clients/live/v1/async_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepgram/clients/live/v1/async_client.py b/deepgram/clients/live/v1/async_client.py index cfcd33b0..31f7f92f 100644 --- a/deepgram/clients/live/v1/async_client.py +++ b/deepgram/clients/live/v1/async_client.py @@ -336,7 +336,7 @@ async def _keep_alive(self) -> None: counter += 1 await asyncio.sleep(ONE_SECOND) - if self._exit_event is not None and self._exit_event.is_set():: + if self._exit_event is not None and self._exit_event.is_set(): self.logger.notice("_keep_alive exiting gracefully") self.logger.debug("AsyncLiveClient._keep_alive LEAVE") return