cpython/Lib/test/mp_fork_bomb.py
Richard Oudkerk e88a2445bc Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
on Windows without the "if __name__ == '__main__'" idiom.
2012-08-14 11:41:32 +01:00

14 lines
323 B
Python

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.
p = multiprocessing.Process(target=foo)
p.start()
p.join()
sys.exit(p.exitcode)