Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (19k points)

In the Python multiprocessing library, is there a variant of pool.map which support multiple arguments?

text = "test"

def harvester(text, case):

X = case[0]

text+ str(X)

if __name__ == '__main__':

pool = multiprocessing.Pool(processes=6)

case = RAW_DATASET pool.map(harvester(text,case),case, 1) pool.close()

pool.join()

1 Answer

0 votes
by (106k points)

You can use the following code this code supports the multiple arguments:-

def multi_run_wrapper(args):

return add(*args)

def add(x,y):

return x+y

if __name__ == "__main__":

from multiprocessing import Pool

pool = Pool(4)

results = pool.map(multi_run_wrapper,[(1,2),(2,3),(3,4)])

print results

If You want to learn python for data science visit this python course by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jun 27, 2019 in Python by Sammy (47.6k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.7k users

Browse Categories

...