1

I'm new to multiprocessing but I'm having trouble even starting the processes. Even the below code snippet from python's documentation does not print anything

from multiprocessing import Process

def f(name):
    print('hello', name)

if __name__ == '__main__':
    p = Process(target=f, args=('bob',))
    p.start()
    p.join()

I went through this similar question and their solution does not work for me.

I'm running python 3.8.2 on Jupyter Notebook

angryweasel
  • 316
  • 2
  • 10

2 Answers2

1

https://docs.python.org/3/library/multiprocessing.html

Functionality within this package requires that the main module be importable by the children. This is covered in Programming guidelines however it is worth pointing out here. This means that some examples, such as the multiprocessing.pool.Pool examples will not work in the interactive interpreter.

Try to execute it as a .py script via console.

zot8
  • 97
  • 9
1

I used the newest version Anaconda 2020.11 to installed python Jupyter Notebook 6.1.4, JupterLab 2.26, and Spyder 4.1.5 etc., they all cannot run Process().start() called functions and do not show error.

The CMD.exe Prompt can run Process functions in .py files just fine.

HardyWu
  • 11
  • 1