O'Reilly logo

Python Parallel Programming Cookbook by Giancarlo Zaccone

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to use a process pool

The multiprocessing library provides the Pool class for simple parallel processing tasks. The Pool class has the following methods:

  • apply(): It blocks until the result is ready.
  • apply_async(): This is a variant of the apply() method, which returns a result object. It is an asynchronous operation that will not lock the main thread until all the child classes are executed.
  • map(): This is the parallel equivalent of the map() built-in function. It blocks until the result is ready, this method chops the iterable data in a number of chunks that submits to the process pool as separate tasks.
  • map_async(): This is a variant of the map() method, which returns a result object. If a callback is specified, then it should be callable, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required