Running Two Simple Processes
A simple example of using multiple processes would be two processes (workers) that are executed separately. In the following example, two processes are started:
countUp() counts 1 up, every second.
countDown() counts 1 down, every second.
The output is as follows:
Using Pool and Map
Pool is a class which manages multiple
Workers (processes) behind the scenes and lets you, the programmer, use.
Pool(5) creates a new Pool with 5 processes, and
pool.map works just like map but it uses multiple processes (the amount defined when creating the pool).
Similar results can be achieved using
apply_async which can be found in the documentation.
This modified text is an extract of the original Stack Overflow Documentation created by following contributors
and released under CC BY-SA 3.0