Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

multiple arguments with multiprocessing python

import multiprocessing
from functools import partial

data_list = [1, 2, 3, 4]

def prod_xy(x,y):
    return x * y

def parallel_runs(data_list):
    pool = multiprocessing.Pool(processes=4)
    prod_x=partial(prod_xy, y=10) # prod_x has only one argument x (y is fixed to 10)
    result_list = pool.map(prod_x, data_list)
    print(result_list)

if __name__ == '__main__':
    parallel_runs(data_list)
Comment

PREVIOUS NEXT
Code Example
Python :: pygame.events 
Python :: .split python 
Python :: Python code to find Area of Rectangle 
Python :: disable gpu in jupyter notebook in tensorflow 
Python :: how to get user input python 
Python :: floating point python 
Python :: python gui 
Python :: python dictionary sort by value then alphabetically 
Python :: sys.maxsize in python 
Python :: dropna pandas 
Python :: no module named googlesearch 
Python :: how to get the last value in a list python 
Python :: python urlparse get domain 
Python :: regex_2/_regex.c:50:10: fatal error: Python.h: No such file or directory 
Python :: logging.basicConfig() 
Python :: four digit representation python 
Python :: pytorch version python command 
Python :: python start process in background and get pid 
Python :: np.random.exponential 
Python :: django pagination class based views 
Python :: uninstall python3 from source on centos 7 
Python :: rust vs python 
Python :: Reverse an string Using Stack in Python 
Python :: run a python script from another python script on a raspberry pi 
Python :: python replace n with actual new line 
Python :: len python 
Python :: renpy 
Python :: absolute url 
Python :: pyton do while loop+ 
Python :: regex find email address in string python 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =