Skip to content

Parallelizing Analysis using PyLOOS and LOOS #48

Answered by krb0073
krb0073 asked this question in Q&A
Discussion options

You must be logged in to vote

That is actually really helpful for another project that I am working with. After some digging I found that this worked well to run a function over parallel from within the python scripts.

import multiprocessing as mp
# variable list will hold a list of tuples which each inner list defines the variables to use per run 
var_list = []
A = [5] *10
B = [x for x in range(11)]
C = [x  -1 for x in range(11)]
def product(a,b,c):
    return a* 2b * c
pool = mp.Pool(processes=n_cores) # make a object # get the pool of processors used
ans = pool.starmap(product,zip(A,B,C))
pool.close() # release the cores for now  
pool.join() # Blocks until all items in the queue have been gotten and processed

it i…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by agrossfield
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants