I have a loop that I've been trying to speed up. I noticed that Python was only using a single core, so I imported the multiprocessing package and set up a pool. Now the whole process is distributed over a number of cores but they seem to be limited to ~10 %.
Is this expected/optimal? Or is there a way to utilise a more from each core?
Code:
from multiprocessing.dummy import Pool as ThreadPool
//...more code here...
pool = ThreadPool(os.cpu_count())
pool.starmap(getSubject, zip(range(1, Nsub)))
pool.close()
pool.join()
ps. Before using Pool
htop would show one core at 100 % and the others at ~0 %.