colour.utilities.ParallelForThread#
- class colour.utilities.ParallelForThread(*args: Any, **kwargs: Any)[source]#
Bases:
ControlFlowNodeDefine an advanced
forloop node that distributes work across multiple threads for parallel execution.Each generated task receives one
indexandelementoutput port value. The tasks are executed by aconcurrent.futures.ThreadPoolExecutorclass instance. The futures results are collected, sorted, and assigned to theresultsoutput port.Upon completion, the
colour.utilities.ExecutionNode.process()method of the object connected to theexecution_outputoutput port is called.Notes
The
colour.utilities.ParallelForThreadloop node does not currently call more than the two aforementionedcolour.utilities.ExecutionNode.process()methods. If a series of nodes is attached to theloop_outputorexecution_outputoutput ports, only the left-most node will be processed. To circumvent this limitation, it is recommended to use acolour.utilities.PortGraphclass 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.ParallelForMultiprocessloop node instead.
Return a new instance of the
colour.utilities.TreeNodeclass.