Class: QgsTaskManager¶
Task manager for managing a set of long-running QgsTask
tasks.
This class can be created directly, or accessed via
QgsApplication.taskManager().
Class Hierarchy¶
Base classes¶
- class qgis.core.QgsTaskManager[source]¶
Bases:
QObject- __init__(parent: QObject | None = None)
Constructor for QgsTaskManager.
- Parameters:
parent (Optional[QObject] = None) – parent QObject
- class TaskDefinition¶
Bases:
objectDefinition of a task for inclusion in the manager.
- dependentTasks: QgsTaskList¶
- addTask(self, task: QgsTask | None, priority: int = 0) int[source]¶
Adds a task to the manager. Ownership of the task is transferred to the manager, and the task manager will be responsible for starting the task. The priority argument can be used to control the run queue’s order of execution, with larger numbers taking precedence over lower priority numbers.
- Returns:
unique task ID, or 0 if task could not be added
addTask(self, task: QgsTaskManager.TaskDefinition, priority: int = 0) -> int Adds a task to the manager, using a full task definition (including dependency handling). Ownership of the task is transferred to the manager, and the task manager will be responsible for starting the task. The priority argument can be used to control the run queue’s order of execution, with larger numbers taking precedence over lower priority numbers.
- Return type:
int
- Returns:
unique task ID, or 0 if task could not be added
- Parameters:
task (Optional[QgsTask])
priority (int = 0)
- signal allTasksFinished[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- cancelAll(self)[source]¶
Instructs all tasks tracked by the manager to terminate. Individual tasks may take some time to cancel, or may totally ignore this instruction. Calling this does not block but will instead signal the tasks to cancel and then return immediately.
- countActiveTasks(self, includeHidden: bool = True) int[source]¶
Returns the number of active (queued or running) tasks.
The
includeHiddenargument dictates whether hidden tasks should be shown.See also
See also
- Parameters:
includeHidden (bool = True)
- Return type:
int
- signal countActiveTasksChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- dependenciesSatisfied(self, taskId: int) bool[source]¶
Returns
Trueif all dependencies for the specified task are satisfied- Parameters:
taskId (int)
- Return type:
bool
- dependentLayers(self, taskId: int) List[QgsMapLayer]¶
Returns a list of layers on which as task is dependent. The task will automatically be canceled if any of these layers are about to be removed.
- Parameters:
taskId (int) – task ID
- Return type:
- Returns:
list of layers
See also
- signal finalTaskProgressChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal progressChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal statusChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- task(self, id: int) QgsTask | None[source]¶
Returns the task with matching ID.
- Parameters:
id (int) – task ID
- Return type:
Optional[QgsTask]
- Returns:
task if found, or
None
- signal taskAboutToBeDeleted[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- signal taskAdded[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- taskId(self, task: QgsTask | None) int[source]¶
Returns the unique task ID corresponding to a task managed by the class.
- Parameters:
task (Optional[QgsTask]) – task to find
- Return type:
int
- Returns:
task ID, or -1 if task not found
- signal taskTriggered[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- tasksDependentOnLayer(self, layer: QgsMapLayer | None) List[QgsTask]¶
Returns a list of tasks which depend on a layer.
See also
- Parameters:
layer (Optional[QgsMapLayer])
- Return type:
- threadPool(self) QThreadPool | None[source]¶
Returns the threadpool utilized by the task manager.
Added in version 3.34.
- Return type:
Optional[QThreadPool]