used. The examples are simple in the sense that the calculation jobs are completely
input arguments and pass back the result. However, this is not an uncommon situation in
can be run separately on independent input data.
For our examples
we make three imports, one for the Process class, which is the
simplest way of generating a parallel job, another for Queue, which allows data to be
shared between jobs, and Pool, which provides a convenient way of matching a fixed
number of processing cores with a variable number of sub-tasks; the pooling mechanism
collects jobs to be run and then allocates them to the processor when there is a free slot.
from multiprocessing import Process, Queue, Pool
Do'stlaringiz bilan baham: