Skip to content
Advertisement

RuntimeError:freeze_support() on Mac

I’m new on python. I want to learn how to parallel processing in python. I saw the following example:


JavaScript

but when I run it, this error happened:

JavaScript

What should I do?

Advertisement

Answer

If you place everything in global scope inside this if __name__ == "__main__" block as follows, you should find that your program behaves as you expect:

JavaScript

Without this protection, if your current module was imported from a different module, your multiprocessing code would be executed. This could occur within a non-main process spawned in another Pool and spawning processes from sub-processes is not allowed, hence we protect against this problem.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement