0

I'm using Version: 1.73.1 of VSCode with Python 3.10. This script:

from multiprocessing import Process

def foo(i):
  print(i)

for i in range(12):
  Process(target=foo, args=(i,)).start()

runs fine inside VSCode on Ubuntu 22.04.1, but fails on Windows 10 with this error message:

RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

Indeed, adding the "proper idiom" makes it run correctly. Why this difference between the two OSes?

Paul Jurczak
  • 7,008
  • 3
  • 47
  • 72

0 Answers0