Multithreaded Worker Framework
QRunnable multithreaded worker framework: callback execution in Worker + WorkerSignals signalling back to the main thread.
Overview
quatm/GUI/widgets/helper_workers.py (and the isomorphic browser_workers.py) provides the
multithreaded worker framework: Worker subclasses QRunnable and puts an arbitrary callback
function into the QThreadPool thread pool for execution, and returns the result to the GUI main
thread through WorkerSignals using finished / error / result / progress signals.
browser_workers: used by the experiment browser (experiment queue, looper, etc.);helper_workers: used by alignment/auxiliary and similar tools.
Components
| Component | Description |
|---|---|
Worker | QRunnable worker thread: setup, execution and teardown (including exception handling) |
WorkerSignals | Signals a worker thread can emit: finished / error / result / progress, etc. |
Usage
from quatm.GUI.widgets.helper_workers import Worker
worker = Worker(fn=long_running, args=(...), kwargs={...})
worker.signals.result.connect(on_result) # main-thread slot
worker.signals.error.connect(on_error)
QThreadPool.globalInstance().start(worker)
For a fuller description see Background worker threads.