Background worker threads
Worker/WorkerSignals: a generic QRunnable background-task wrapper.
Overview
quatm/GUI/widgets/browser_workers.py and helper_workers.py provide a generic background-thread
wrapper based on QRunnable: time-consuming tasks are executed in a thread pool, and
results/exceptions/progress are passed back to the GUI thread through signals.
Signals
| Signal | Description |
|---|---|
finished | Task completed (no data) |
error(tuple) | (exception type, value, traceback string) |
result(object) | The result returned by processing, of any type |
progress(int) | Progress percentage |
Usage
from quatm.GUI.widgets.browser_workers import Worker
worker = Worker(callback=my_long_task, arg1, kw=...) # passed through to the callback
worker.signals.finished.connect(on_done)
worker.signals.error.connect(on_error)
QThreadPool.globalInstance().start(worker)
The two implementations are largely the same: helper_workers.py is reused for helper/analysis
background tasks, while browser_workers.py is reused for browser-style panels.