Skip to main content
added 107 characters in body
Source Link
ThiPa
  • 659
  • 2
  • 10

This should work aswellas well. Using the addSubTask method, add subtasks to the first task and create dependencies. The downside is: only the main task is shown in TaskManager, meaning tasks can't be canceled individually.

With this code, tasks are executed in order 1 2 3 0.

"""Preparing QgsTasks:"""
# tasklist
tasklist = [task0,task1,task2,task3]
# add all tasks, except first, recursevly as subtask to first task
subtasks = []
for i in range(1, len(tasklist)):
    tasklist[0].addSubTask(tasklist[i], subtasks, QgsTask.ParentDependsOnSubTask)
    subtasks.append(tasklist[i])
# pass only the first task to the taskManager
QgsApplication.taskManager().addTask(tasklist[0])

With this code, they will be executed in order 0 1 2 3:

"""Preparing QgsTasks:"""
# tasklist
tasklist = [task0,task1,task2,task3]
# add all tasks, except last task, recursevly as subtask to last task
subtasks = []
for i in range(0, len(tasklist)):
    tasklist[len(tasklist)-1].addSubTask(tasklist[i], subtasks, QgsTask.ParentDependsOnSubTask)
    subtasks.append(tasklist[i])
# pass only the last task to the taskManager
QgsApplication.taskManager().addTask(tasklist[len(tasklist)-1])

This should work aswell. Using the addSubTask method, add subtasks to the first task and create dependencies.

With this code, tasks are executed in order 1 2 3 0.

"""Preparing QgsTasks:"""
# tasklist
tasklist = [task0,task1,task2,task3]
# add all tasks, except first, recursevly as subtask to first task
subtasks = []
for i in range(1, len(tasklist)):
    tasklist[0].addSubTask(tasklist[i], subtasks, QgsTask.ParentDependsOnSubTask)
    subtasks.append(tasklist[i])
# pass only the first task to the taskManager
QgsApplication.taskManager().addTask(tasklist[0])

With this code, they will be executed in order 0 1 2 3:

"""Preparing QgsTasks:"""
# tasklist
tasklist = [task0,task1,task2,task3]
# add all tasks, except last task, recursevly as subtask to last task
subtasks = []
for i in range(0, len(tasklist)):
    tasklist[len(tasklist)-1].addSubTask(tasklist[i], subtasks, QgsTask.ParentDependsOnSubTask)
    subtasks.append(tasklist[i])
# pass only the last task to the taskManager
QgsApplication.taskManager().addTask(tasklist[len(tasklist)-1])

This should work as well. Using the addSubTask method, add subtasks to the first task and create dependencies. The downside is: only the main task is shown in TaskManager, meaning tasks can't be canceled individually.

With this code, tasks are executed in order 1 2 3 0.

"""Preparing QgsTasks:"""
# tasklist
tasklist = [task0,task1,task2,task3]
# add all tasks, except first, recursevly as subtask to first task
subtasks = []
for i in range(1, len(tasklist)):
    tasklist[0].addSubTask(tasklist[i], subtasks, QgsTask.ParentDependsOnSubTask)
    subtasks.append(tasklist[i])
# pass only the first task to the taskManager
QgsApplication.taskManager().addTask(tasklist[0])

With this code, they will be executed in order 0 1 2 3:

"""Preparing QgsTasks:"""
# tasklist
tasklist = [task0,task1,task2,task3]
# add all tasks, except last task, recursevly as subtask to last task
subtasks = []
for i in range(0, len(tasklist)):
    tasklist[len(tasklist)-1].addSubTask(tasklist[i], subtasks, QgsTask.ParentDependsOnSubTask)
    subtasks.append(tasklist[i])
# pass only the last task to the taskManager
QgsApplication.taskManager().addTask(tasklist[len(tasklist)-1])
Source Link
ThiPa
  • 659
  • 2
  • 10

This should work aswell. Using the addSubTask method, add subtasks to the first task and create dependencies.

With this code, tasks are executed in order 1 2 3 0.

"""Preparing QgsTasks:"""
# tasklist
tasklist = [task0,task1,task2,task3]
# add all tasks, except first, recursevly as subtask to first task
subtasks = []
for i in range(1, len(tasklist)):
    tasklist[0].addSubTask(tasklist[i], subtasks, QgsTask.ParentDependsOnSubTask)
    subtasks.append(tasklist[i])
# pass only the first task to the taskManager
QgsApplication.taskManager().addTask(tasklist[0])

With this code, they will be executed in order 0 1 2 3:

"""Preparing QgsTasks:"""
# tasklist
tasklist = [task0,task1,task2,task3]
# add all tasks, except last task, recursevly as subtask to last task
subtasks = []
for i in range(0, len(tasklist)):
    tasklist[len(tasklist)-1].addSubTask(tasklist[i], subtasks, QgsTask.ParentDependsOnSubTask)
    subtasks.append(tasklist[i])
# pass only the last task to the taskManager
QgsApplication.taskManager().addTask(tasklist[len(tasklist)-1])