Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 5c4568a05a0a62b5947c55f68f9f2ecfb90a4f12 authored by Ned Deily on 22 December 2016, 23:38:47 UTC
Update docs and patchlevel for 3.6.0 final.
Tip revision: 5c4568a
mp_fork_bomb.py
import multiprocessing, sys

def foo():
    print("123")

# Because "if __name__ == '__main__'" is missing this will not work
# correctly on Windows.  However, we should get a RuntimeError rather
# than the Windows equivalent of a fork bomb.

if len(sys.argv) > 1:
    multiprocessing.set_start_method(sys.argv[1])
else:
    multiprocessing.set_start_method('spawn')

p = multiprocessing.Process(target=foo)
p.start()
p.join()
sys.exit(p.exitcode)
back to top