Processes in python

Why does the Process class of multiprocessing have to be called in if _ name__= "_ _ main__", otherwise an error is reported? This situation only exists in Windows, and it is impossible to understand the interpretation on the Internet

.
Since Windows has no fork, the multiprocessing module starts a new Python process and imports the calling module. If Process () gets called upon import, then this sets off an infinite succession of new processes (or until your machine runs out of resources). This is the reason for hiding calls to Process () insideif name = "_ _ main__" since statements inside this if-statement will not get called upon import.
Link: https://www.zhihu.com/questio.
Mar.14,2021

this post only states that windows does not have fork, and then says that windows python implements multiple processes with multiprocessing module. It is realized that the code of process () will be dead if it is import without ifXxxxxxxx.
the fact that fork is the way for unix and linix to achieve multiple processes is different from windows. Please understand fork first. I'm sorry, I don't understand, just put forward a direction

.
Menu