Starting a process

Let's now see an equivalent example, but instead of using a thread, we'll use a process:

# start_proc.py
import multiprocessing

...

p = multiprocessing.Process(
target=sum_and_product, name='SumProdProc', args=(7, 9)
)
p.start()

The code is exactly the same as for the first example, but instead of using a Thread, we actually instantiate multiprocessing.Process. The sum_and_product function is the same as before. The output is also the same, except the numbers are different.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.100.180