All CPUs of the computer running the scripts will be called at the same time. The job handler (thrd-m.py) see all CPUs available as a pool, it fetches jobs from a list stored in it. The jobs are 10 copies of a time killing work (long01.py) which generates the number pi from a series.
- Check the number of CPUs available.
- Define a multiprocessing pool.
- Fetch jobs from a list and submit them, one by one, to the pool.
- Wait for the completion of all jobs.
Source Code
Here is the job handler (thrd-m.py)
Here is the time killing process (long01.py)
A sample result of running thrd-m.py by a Core i5 is given below
No comments:
Post a Comment