1import multiprocessing, sys 2 3def foo(): 4 print("123") 5 6# Because "if __name__ == '__main__'" is missing this will not work 7# correctly on Windows. However, we should get a RuntimeError rather 8# than the Windows equivalent of a fork bomb. 9 10if len(sys.argv) > 1: 11 multiprocessing.set_start_method(sys.argv[1]) 12else: 13 multiprocessing.set_start_method('spawn') 14 15p = multiprocessing.Process(target=foo) 16p.start() 17p.join() 18sys.exit(p.exitcode) 19