I have this file (it doesn\'t make any useful work, it\'s only for learning):
import multiprocessing,sys
def parent(numproc=2):
print (\'at start\')
The subprocess has the following __name__
: __parents_main__
and not __main__
any more. This is why your process does not loop when you are testign the __name__
variable.
For more information on this have a look to the chapter Safe importing of main module
This is an issue with multiprocessing
on MS Windows: the main module is imported by the child tasks, so any code not protected by the if __name__ . . .
clause gets run again, resulting in an infinite loop.