Back

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

I have not seen clear examples with use-cases for Pool.apply, Pool.apply_async and Pool.map. I am mainly using Pool.map; what are the advantages of others?

1 Answer

0 votes
by (106k points)

You can use pool.apply(f, args):  in the argument, the f is only executed in one of the workers of the pool. So one of the processes in the pool will run f(args).

The Pool.apply_async method has a callback which, if supplied, is called when the function is complete. This can be used instead of calling get().

Whereas pool.map(f, iterable) chops the iterable into a number of chunks which it submits to the process pool as separate tasks. So you take advantage of all the processes in the pool.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jun 27, 2019 in Python by Sammy (47.6k points)
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

...