File: threading.md

package info (click to toggle)
superqt 0.7.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,320 kB
  • sloc: python: 9,108; makefile: 16; sh: 12
file content (36 lines) | stat: -rw-r--r-- 1,148 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Thread workers

The objects in this module provide utilities for running tasks in a separate
thread. In general (with the exception of `new_worker_qthread`), everything
here wraps Qt's [QRunnable API](https://doc.qt.io/qt-6/qrunnable.html).

The highest level object is the
[`@thread_worker`][superqt.utils.thread_worker] decorator.  It was originally
written for `napari`, and was later extracted into `superqt`.  You may also be
interested in reading the [napari
documentation](https://napari.org/stable/guides/threading.html#threading-in-napari-with-thread-worker) on this feature,
which provides a more in-depth/introductory usage guide.

For additional control, you can create your own
[`FunctionWorker`][superqt.utils.FunctionWorker] or
[`GeneratorWorker`][superqt.utils.GeneratorWorker] objects.

::: superqt.utils.WorkerBase

::: superqt.utils.FunctionWorker

::: superqt.utils.GeneratorWorker

## Convenience functions

::: superqt.utils.thread_worker
    options:
        heading_level: 3

::: superqt.utils.create_worker
    options:
        heading_level: 3

::: superqt.utils.new_worker_qthread
    options:
        heading_level: 3