From d410e14e0e919c739ecd351ff3b3bd9dfb43f622 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sat, 17 Aug 2024 18:56:33 +0430 Subject: [PATCH] fix : NavaThread run method updated --- nava/thread.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/nava/thread.py b/nava/thread.py index f281d74..2a44f4a 100644 --- a/nava/thread.py +++ b/nava/thread.py @@ -2,7 +2,8 @@ """Nava thread.""" import threading -from .params import Engine +from .params import Engine, SOUND_FILE_PLAY_ERROR +from .errors import NavaBaseError class NavaThread(threading.Thread): @@ -32,15 +33,18 @@ def run(self): :return: None """ - if self._target is not None: - if self._engine == Engine.WINSOUND: - self._play_process = self._target(*self._args, **self._kwargs) - else: - while True: + try: + if self._target is not None: + if self._engine == Engine.WINSOUND: self._play_process = self._target(*self._args, **self._kwargs) - self._play_process.wait() - if not self._loop: - break + else: + while True: + self._play_process = self._target(*self._args, **self._kwargs) + self._play_process.wait() + if not self._loop: + break + except Exception: + raise NavaBaseError(SOUND_FILE_PLAY_ERROR) def stop(self): """