colour.utilities.ParallelForThread#

class colour.utilities.ParallelForThread(*args: Any, **kwargs: Any)[source]#

Bases: ControlFlowNode

Define an advanced for loop node that distributes work across multiple threads for parallel execution.

Each generated task receives one index and element output port value. The tasks are executed by a concurrent.futures.ThreadPoolExecutor class instance. The futures results are collected, sorted, and assigned to the results output port.

Upon completion, the colour.utilities.ExecutionNode.process() method of the object connected to the execution_output output port is called.

Notes

  • The colour.utilities.ParallelForThread loop node does not currently call more than the two aforementioned colour.utilities.ExecutionNode.process() methods. If a series of nodes is attached to the loop_output or execution_output output ports, only the left-most node will be processed. To circumvent this limitation, it is recommended to use a colour.utilities.PortGraph class instance.

  • As the graph being processed is shared across the threads, a lock must be taken in the task callable. This might nullify any speed gains for heavy processing tasks. In such eventuality, it is recommended to use the colour.utilities.ParallelForMultiprocess loop node instead.

Return a new instance of the colour.utilities.TreeNode class.

Parameters:
  • args (Any) – Arguments.

  • kwargs (Any) – Keywords arguments.

__init__(*args: Any, **kwargs: Any) None[source]#
Parameters:
Return type:

None

process() None[source]#

Process the parallel loop node execution.

Return type:

None