Skip to content

Commit

Permalink
Merge pull request #365 from jkroll-deepgram/handle-exit-event
Browse files Browse the repository at this point in the history
Handle NoneType exit event
  • Loading branch information
dvonthenen committed Apr 16, 2024
2 parents 81e2940 + 201843f commit 7461d02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions deepgram/clients/live/v1/async_client.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions deepgram/clients/live/v1/client.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7461d02

Please sign in to comment.