Skip to content

Commit

Permalink
Auto YAPF with Google python style
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Dec 24, 2024
1 parent 7d5b9c7 commit 8a298d6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions stream_translator_gpt/llm_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def _trigger(self, translation_task: TranslationTask):
thread = threading.Thread(target=self.llm_client.translate, args=(translation_task,))
thread.daemon = True
thread.start()

def _retrigger_failed_tasks(self):
for task in self.processing_queue:
if task.translation_failed and not _is_task_timeout(task, self.timeout):
Expand All @@ -188,7 +188,9 @@ def _retrigger_failed_tasks(self):

def _get_results(self):
results = []
while self.processing_queue and (self.processing_queue[0].translated_text or _is_task_timeout(self.processing_queue[0], self.timeout) or (self.processing_queue[0].translation_failed and not self.retry_if_translation_fails)):
while self.processing_queue and (
self.processing_queue[0].translated_text or _is_task_timeout(self.processing_queue[0], self.timeout) or
(self.processing_queue[0].translation_failed and not self.retry_if_translation_fails)):
task = self.processing_queue.popleft()
if not task.translated_text:
if _is_task_timeout(task, self.timeout):
Expand Down Expand Up @@ -231,7 +233,8 @@ def loop(self, input_queue: queue.SimpleQueue[TranslationTask], output_queue: qu
current_task = None
while True:
if current_task:
if (current_task.translated_text or current_task.translation_failed or _is_task_timeout(current_task, self.timeout)):
if (current_task.translated_text or current_task.translation_failed or
_is_task_timeout(current_task, self.timeout)):
if not current_task.translated_text:
if _is_task_timeout(current_task, self.timeout):
print('Translation timeout: {}'.format(current_task.transcribed_text))
Expand Down

0 comments on commit 8a298d6

Please sign in to comment.