mirror of
https://github.com/chidiwilliams/buzz.git
synced 2026-03-14 14:45:46 +01:00
Add test timeout (#1277)
This commit is contained in:
parent
e5843d7668
commit
10e74edf89
16 changed files with 30 additions and 22 deletions
|
|
@ -41,11 +41,11 @@ Install with [brew utility](https://brew.sh/)
|
|||
brew install --cask buzz
|
||||
```
|
||||
|
||||
Or download the `.dmg` from the [releases page](https://github.com/chidiwilliams/buzz/releases/latest).
|
||||
Or download the `.dmg` from the [SourceForge](https://sourceforge.net/projects/buzz-captions/files/).
|
||||
|
||||
### Windows
|
||||
|
||||
Download and run the `.exe` from the [releases page](https://github.com/chidiwilliams/buzz/releases/latest).
|
||||
Get the installation files from the [SourceForge](https://sourceforge.net/projects/buzz-captions/files/).
|
||||
|
||||
App is not signed, you will get a warning when you install it. Select `More info` -> `Run anyway`.
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,8 @@ class DBMigrator:
|
|||
msg_argv += (args,)
|
||||
else:
|
||||
args = []
|
||||
logging.info(msg_tmpl, *msg_argv)
|
||||
# Uncomment this to get debugging information
|
||||
# logging.info(msg_tmpl, *msg_argv)
|
||||
self.db.execute(sql, args)
|
||||
self.n_changes += 1
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class FileTranscriberQueueWorker(QObject):
|
|||
self.current_transcriber.stop()
|
||||
|
||||
if self.current_transcriber_thread is not None:
|
||||
if not self.current_transcriber_thread.wait(3000):
|
||||
if not self.current_transcriber_thread.wait(5000):
|
||||
logging.warning("Transcriber thread did not terminate gracefully")
|
||||
self.current_transcriber_thread.terminate()
|
||||
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ class RecordingTranscriber(QObject):
|
|||
self.is_running = False
|
||||
if self.process and self.process.poll() is None:
|
||||
self.process.terminate()
|
||||
self.process.wait()
|
||||
self.process.wait(5000)
|
||||
|
||||
def start_local_whisper_server(self):
|
||||
self.transcription.emit(_("Starting Whisper.cpp..."))
|
||||
|
|
@ -416,4 +416,4 @@ class RecordingTranscriber(QObject):
|
|||
def __del__(self):
|
||||
if self.process and self.process.poll() is None:
|
||||
self.process.terminate()
|
||||
self.process.wait()
|
||||
self.process.wait(5000)
|
||||
|
|
@ -274,11 +274,11 @@ class WhisperFileTranscriber(FileTranscriber):
|
|||
if self.started_process:
|
||||
self.current_process.terminate()
|
||||
# Use timeout to avoid hanging indefinitely
|
||||
self.current_process.join(timeout=5)
|
||||
self.current_process.join(timeout=10)
|
||||
if self.current_process.is_alive():
|
||||
logging.warning("Process didn't terminate gracefully, force killing")
|
||||
self.current_process.kill()
|
||||
self.current_process.join(timeout=2)
|
||||
self.current_process.join(timeout=5)
|
||||
|
||||
# Close pipes to unblock the read_line thread
|
||||
try:
|
||||
|
|
@ -291,7 +291,7 @@ class WhisperFileTranscriber(FileTranscriber):
|
|||
|
||||
# Join read_line_thread with timeout to prevent hanging
|
||||
if self.read_line_thread and self.read_line_thread.is_alive():
|
||||
self.read_line_thread.join(timeout=3)
|
||||
self.read_line_thread.join(timeout=5)
|
||||
if self.read_line_thread.is_alive():
|
||||
logging.warning("Read line thread didn't terminate gracefully")
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ class Translator(QObject):
|
|||
messages=[
|
||||
{"role": "system", "content": self.transcription_options.llm_prompt},
|
||||
{"role": "user", "content": transcript}
|
||||
]
|
||||
],
|
||||
timeout=30.0
|
||||
)
|
||||
except Exception as e:
|
||||
completion = None
|
||||
|
|
|
|||
|
|
@ -425,7 +425,7 @@ class MainWindow(QMainWindow):
|
|||
|
||||
self.transcriber_worker.stop()
|
||||
self.transcriber_thread.quit()
|
||||
self.transcriber_thread.wait()
|
||||
self.transcriber_thread.wait(5000) # Wait up to 5 seconds
|
||||
|
||||
if self.transcription_viewer_widget is not None:
|
||||
self.transcription_viewer_widget.close()
|
||||
|
|
|
|||
|
|
@ -624,6 +624,10 @@ class RecordingTranscriberWidget(QWidget):
|
|||
if self.translator is not None:
|
||||
self.translator.stop()
|
||||
|
||||
if self.translation_thread is not None:
|
||||
self.translation_thread.quit()
|
||||
self.translation_thread.wait(35_000) # Wait up to 35 seconds
|
||||
|
||||
self.settings.set_value(
|
||||
Settings.Key.RECORDING_TRANSCRIBER_LANGUAGE,
|
||||
self.transcription_options.language,
|
||||
|
|
|
|||
|
|
@ -1348,7 +1348,7 @@ class TranscriptionViewerWidget(QWidget):
|
|||
|
||||
self.translator.stop()
|
||||
self.translation_thread.quit()
|
||||
self.translation_thread.wait()
|
||||
self.translation_thread.wait(35_000) # Wait up to 35 seconds, translation thread also has timeouts, wait longer
|
||||
|
||||
super().closeEvent(event)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,5 +5,7 @@ qt_api=pyqt6
|
|||
log_format = %(asctime)s %(levelname)s %(module)s::%(funcName)s %(message)s
|
||||
log_date_format = %Y-%m-%d %H:%M:%S
|
||||
addopts = -x
|
||||
timeout = 600
|
||||
timeout_method = thread
|
||||
markers =
|
||||
timeout: set a timeout on a test function.
|
||||
|
|
@ -20,7 +20,7 @@ class TestCLI:
|
|||
"--task",
|
||||
"transcribe",
|
||||
"--model-size",
|
||||
"small",
|
||||
"tiny",
|
||||
"--output-directory",
|
||||
mkdtemp(),
|
||||
"--txt",
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from buzz.widgets.transcriber.advanced_settings_dialog import AdvancedSettingsDi
|
|||
class TestTranslator:
|
||||
@patch('buzz.translator.OpenAI', autospec=True)
|
||||
@patch('buzz.translator.queue.Queue', autospec=True)
|
||||
def test_start(self, mock_queue, mock_openai):
|
||||
def test_start(self, mock_queue, mock_openai, qtbot):
|
||||
def side_effect(*args, **kwargs):
|
||||
side_effect.call_count += 1
|
||||
|
||||
|
|
@ -106,11 +106,11 @@ class TestTranslator:
|
|||
|
||||
if self.translator is not None:
|
||||
self.translator.stop()
|
||||
self.translator.deleteLater()
|
||||
|
||||
if self.translation_thread is not None:
|
||||
self.translation_thread.quit()
|
||||
self.translation_thread.deleteLater()
|
||||
# Wait for the thread to actually finish before cleanup
|
||||
self.translation_thread.wait()
|
||||
|
||||
# Wait to clean-up threads
|
||||
time.sleep(3)
|
||||
# Note: translator and translation_thread will be automatically deleted
|
||||
# via the deleteLater() connections set up earlier
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class TestExportTranscriptionMenu:
|
|||
file=test_audio_path,
|
||||
task=Task.TRANSCRIBE.value,
|
||||
model_type=ModelType.WHISPER.value,
|
||||
whisper_model_size=WhisperModelSize.SMALL.value,
|
||||
whisper_model_size=WhisperModelSize.TINY.value,
|
||||
)
|
||||
)
|
||||
transcription_segment_dao.insert(TranscriptionSegment(40, 299, "Bien", "", str(id)))
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ class TestTranscriptionSegmentsEditorWidget:
|
|||
file=test_audio_path,
|
||||
task=Task.TRANSCRIBE.value,
|
||||
model_type=ModelType.WHISPER.value,
|
||||
whisper_model_size=WhisperModelSize.SMALL.value,
|
||||
whisper_model_size=WhisperModelSize.TINY.value,
|
||||
)
|
||||
)
|
||||
transcription_segment_dao.insert(
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class TestTranscriptionViewerWidgetAdditional:
|
|||
file=test_audio_path,
|
||||
task=Task.TRANSCRIBE.value,
|
||||
model_type=ModelType.WHISPER.value,
|
||||
whisper_model_size=WhisperModelSize.SMALL.value,
|
||||
whisper_model_size=WhisperModelSize.TINY.value,
|
||||
)
|
||||
)
|
||||
transcription_segment_dao.insert(
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class TestTranscriptionViewerWidget:
|
|||
file=test_audio_path,
|
||||
task=Task.TRANSCRIBE.value,
|
||||
model_type=ModelType.WHISPER.value,
|
||||
whisper_model_size=WhisperModelSize.SMALL.value,
|
||||
whisper_model_size=WhisperModelSize.TINY.value,
|
||||
)
|
||||
)
|
||||
transcription_segment_dao.insert(TranscriptionSegment(40, 299, "Bien", "", str(id)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue