0

I am trying to understand parallel processing using multiprocessing in python using the example given in this link https://pymotw.com/2/multiprocessing/basics.html. Here is the code:

def worker(i):
    """worker function"""
    print('Worker',i)
    return

if __name__ == '__main__':
    jobs = []
    for i in range(5):
        p = multiprocessing.Process(target=worker, args = (i,))
        jobs.append(p)
        p.start()
        p.join()

When I execute this code, I do not get any output in my Jupyter notebook. I also tried other functions but I don't get any output. My python version is 3.8.5.

Thank you.

Aman Savaria
  • 164
  • 1
  • 1
  • 11
  • 1
    It starts a new process. That new process prints something to its standard output, but that is the standard output of a different process, so you cannot see it. I suggest not using `multiprocessing` to print things. The module is useful for seamlessly running calculations in a separate process and gathering the results (return values). – zvone Jan 08 '21 at 16:55
  • 2
    This is related: https://stackoverflow.com/questions/50937362/multiprocessing-on-python-3-jupyter – Random Davis Jan 08 '21 at 16:57

0 Answers0