0 votes
1 view
in Python by (47.8k 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 (107k 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.8k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jun 27, 2019 in Python by Sammy (47.8k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !

Categories

...