Skip to content

Commit

Permalink
Fix queue waiting (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
chidiwilliams committed Apr 26, 2023
1 parent 84ab53d commit bf76627
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ jobs:
benchmark:
runs-on: ${{ matrix.os }}
if: github.ref == 'refs/heads/master'
strategy:
fail-fast: false
matrix:
Expand Down
22 changes: 9 additions & 13 deletions buzz/transcriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,24 +711,20 @@ def __init__(self, parent: Optional[QObject] = None):
def run(self):
logging.debug('Waiting for next transcription task')

# Waiting for new tasks in a loop instead of with queue.wait()
# resolves a "No Python frame" crash when the thread is quit.
# Get next non-canceled task from queue
while True:
try:
self.current_task: Optional[FileTranscriptionTask] = self.tasks_queue.get_nowait()

# Stop listening when a "None" task is received
if self.current_task is None:
self.completed.emit()
return
self.current_task: Optional[FileTranscriptionTask] = self.tasks_queue.get()

if self.current_task.id in self.canceled_tasks:
continue
# Stop listening when a "None" task is received
if self.current_task is None:
self.completed.emit()
return

break
except queue.Empty:
if self.current_task.id in self.canceled_tasks:
continue

break

logging.debug('Starting next transcription task')

model_type = self.current_task.transcription_options.model.model_type
Expand Down
4 changes: 2 additions & 2 deletions tests/gui_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_should_set_window_title_and_icon(self, qtbot):
assert window.windowIcon().pixmap(QSize(64, 64)).isNull() is False
window.close()

@pytest.mark.skip(reason='Timing out or crashing')
# @pytest.mark.skip(reason='Timing out or crashing')
def test_should_run_transcription_task(self, qtbot: QtBot, tasks_cache):
window = MainWindow(tasks_cache=tasks_cache)
qtbot.add_widget(window)
Expand All @@ -163,7 +163,7 @@ def test_should_run_transcription_task(self, qtbot: QtBot, tasks_cache):
table_widget.setCurrentIndex(table_widget.indexFromItem(table_widget.item(0, 1)))
assert open_transcript_action.isEnabled()

@pytest.mark.skip(reason='Timing out or crashing')
# @pytest.mark.skip(reason='Timing out or crashing')
def test_should_run_and_cancel_transcription_task(self, qtbot, tasks_cache):
window = MainWindow(tasks_cache=tasks_cache)
qtbot.add_widget(window)
Expand Down

0 comments on commit bf76627

Please sign in to comment.