Running python 2.7 on windows 7 (64 bit).
When reading documents for the multiprocessing library module, it repeatedly indicates the importance of the __main__ module, including the conditional (especially on Windows):
if __name__ == "__main__":
I understand that you do not want to instantiate Process () in the global namespace of the module (because when a child process imports the module, it will be unpredictable one more by accident).
I do not need to place process managers at the highest level of the package execution hierarchy (execution in PARENT). While my Process () is being created, managed and terminated by a class method, or even when a function is closed. Just not in the top-level module namespace.
Do I understand this warning / requirement correctly?
EDIT
After the first two answers, I add this quote. This is in the introduction for Development 16.6 of multiprocessing from 2.7 documents.
Note. The functionality in this package requires the __main__ module to be imported by children. This is described in the Program, however it is worth mentioning here. This means that some examples, such as multiprocessing.Pool examples, will not work in the interactive interpreter ...
python multiprocessing
user2097818
source share