December 2018
Beginner to intermediate
796 pages
19h 54m
English
To perform the final step, we need to amend only two lines in the previous code. If you have paid attention in the introductory examples, you will know which of the two lines I am referring to. In order to save some space, I'll just give you the diff of the code:
# ms/algo/mergesort_proc.py...from concurrent.futures import ProcessPoolExecutor, as_completed...def sort(v, workers=2): ... with ProcessPoolExecutor(max_workers=workers) as executor: ...
That's it! Basically all you have to do is use ProcessPoolExecutor instead of ThreadPoolExecutor, and instead of spawning threads, you are spawning processes.
Do you recall when I was saying that processes can actually run on different cores, while threads run within the same ...
Read now
Unlock full access