I'm trying to do some multiprocessing with Python with some example code and I can get it to work in Python, but not in Spyder with IPython.
I have a python file: test.py
It contains this example code:
import multiprocessing
def worker():
"""worker function"""
print( 'Worker')
return
if __name__ == '__main__':
print('run this code')
jobs = []
for i in range(5):
p = multiprocessing.Process(target=worker)
jobs.append(p)
p.start()
I am using the Anaconda3 distribution of Python. If I go to the Anaconda prompt and type:
python test.py
The code works as expected.
And, if I try the same thing with the IPython:
IPython test.py
Again, the code works!!
However, I like to do my development in the Spyder IDE that comes with Anaconda3. And in Spyder, the console is IPython.
If I run test.py in Spyder with the IPython console, I get run this code
printing to the console, but the multiprocessing function is not executed and there are no errors reported.
Any idea what's going on here?