It seems the mutiprocessing module is not Mac compatible? The documentation states: "It runs on both Unix and Windows." I guess Unix could include Mac. But when I run the below test code, I see only one Python process running in activity monitor.
This is getting more confusing.
Depending on the values of the two ranges I sometimes see 4 processes running, and sometimes only 1. But even when 4 processes are indeed running, the sum of their cpu load never gets above 100%, which seems to indicate they don't actually run on separate cores.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import multiprocessing as mp import math #import numpy as np def cube(x): a = 1 for i in range ( 1 , 100000000 ): # a=np.random.rand(1)[0] a = math.cos(i) * a return x * * 3 , a pool = mp.Pool(processes = 4 ) results = [pool. apply (cube, args = (x,)) for x in range ( 1 , 7 )] print (results) |
This is getting more confusing.
Depending on the values of the two ranges I sometimes see 4 processes running, and sometimes only 1. But even when 4 processes are indeed running, the sum of their cpu load never gets above 100%, which seems to indicate they don't actually run on separate cores.