Richard Oudkerk | e88a244 | 2012-08-14 11:41:32 +0100 | [diff] [blame] | 1 | import multiprocessing, sys |
| 2 | |
| 3 | def 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 | |
Richard Oudkerk | 84ed9a6 | 2013-08-14 15:35:41 +0100 | [diff] [blame] | 10 | if len(sys.argv) > 1: |
| 11 | multiprocessing.set_start_method(sys.argv[1]) |
| 12 | else: |
| 13 | multiprocessing.set_start_method('spawn') |
| 14 | |
Richard Oudkerk | e88a244 | 2012-08-14 11:41:32 +0100 | [diff] [blame] | 15 | p = multiprocessing.Process(target=foo) |
| 16 | p.start() |
| 17 | p.join() |
| 18 | sys.exit(p.exitcode) |