Actually, freeze_support() is not required here. You get a RuntimeError because you create and start your new processes at the top level of your beta module.
When a new process is created using multiprocessing on Windows, a new Python interpreter will be launched in this process and it will try to import the module with the target function to be executed. This is your beta module. Now, when you import it, all your top-level instructions should be followed, which will lead to the creation and start of a new process. And then, recursively, another process from that process, etc. Etc.
This is most likely not what you want, so new processes should be initialized and started only once when you start beta.py directly using subprocess .
if __name__ == '__main__': should be placed in beta.py, and then move the initialization and run the code for new processes in this section. After that, when beta.py is imported and does not start directly, the new process will not start, and you will not see any side effects.
wombatonfire
source share