Python multiprocessing module
I'm researching about the multiprocessing module and found this 5 years old code. After uncommented the last 2 lines and add a few extra printing, I come up with this code: import multiprocessing as mp def sqr(x): print(f'x: {x}') print(x**2) return x**2 print(mp.cpu_count(), 'cpu count') with mp.Pool(2) as p: p.map(sqr, list(range(10))) It runs fine in the playground. However, when I copied it to IDLE and run it from there, it only prints the number of CPU counts and keep running but no output. Then I switch to powershell and run it, it keeps outputting error message. While the screen rolling fast, I notice RuntimeError if __name__ == '__main__': freeze_support() So I added it at the end, still not working in IDEL & powershell. Then I use vscode, without the if statement, it runs fine without issue. Can anyone explain? https://sololearn.com/compiler-playground/cmaEN3hjgaXf/?ref=app