ยปCore Development>Code coverage>Lib/test/mp_fork_bomb.py

Python code coverage for Lib/test/mp_fork_bomb.py

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