I am playing around with a library for my beginner students, and I\'m using the multiprocessing module in Python. I ran into this problem: importing and using a module that
Windows doesn't have fork
, so there's no way to make a new process just like the existing one. So the child process has to run your code again, but now you need a way to distinguish between the parent process and the child process, and __main__
is it.
This is covered in the docs here: http://docs.python.org/2/library/multiprocessing.html#windows
I don't know of another way to structure the code to avoid the fork bomb effect.