python3.x multiprocessing cycling without “if __name__ == '__main__':”

后端 未结 2 1547
别那么骄傲
别那么骄傲 2021-01-01 07:05

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\')
             


        
2条回答
  •  隐瞒了意图╮
    2021-01-01 07:30

    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

提交回复
热议问题