Let's implement the case study of processing a Fibonacci series for multiple inputs using the processes approach instead of threads.
The multiprocessing_fibonacci.py
code makes use of the multiprocessing
module, and in order to run, it imports some essential modules as we can observe in the following code:
import sys, time, random, re, requests import concurrent.futures from multiprocessing import, cpu_count, current_process, Manager
Some imports have been mentioned in the previous chapters; nevertheless, some of the following imports do deserve special attention:
cpu_count
: This is a function that permits obtaining the quantity of CPUs in a machinecurrent_process
: This is a function that allows obtaining information on the current process, for example, its nameManager
: This is a type of object that allows sharing Python objects among different processes by means of proxies (for more information, see http://docs...