Skip to content

Commit

Permalink
fix : NavaThread run method updated
Browse files Browse the repository at this point in the history
  • Loading branch information
sepandhaghighi committed Aug 17, 2024
1 parent 07ea3ee commit d410e14
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions nava/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit d410e14

Please sign in to comment.