Open bendichter opened 7 years ago
Do you have a version that does this? I'm not too familiar with multiprocessing.pool so if you have an example that would be excellent. We should also have a way of limiting the number of simultaneous processes to limit crashes :)
Yeah that's precisely what pool does
import multiprocessing
import subprocess
def work(cmd):
return subprocess.call(cmd, shell=False)
count = multiprocessing.cpu_count()
pool = multiprocessing.Pool(processes=count)
print pool.map(work, list_of_commands)
though I was thinking it might be better to take everything inside of for c in np.arange(len(surface_indices)):
and put it into the a function called warp_single_electrode
and have that be the work
function. Then use partial
to fill in the arguments of warp_single_electrode
except for c
and then call pool.map(warp_single_electrode, np.arange(len(surface_indices)))
That makes sense -- have every electrode warp as a single "job". What is partial
here?
partial
allows you to fill in optional arguments of a function. In this case, you I think you can only pass one argument in pool.map, so you could use partial to pass all of the constant variables like hem
, template
, etc.
Electrode warping can be massively sped up by parallelization. We should probably use
submit_job
for warps on the server andmultiprocessing.pool
for warps on individual computers.