mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
on Windows without the "if __name__ == '__main__'" idiom.
This commit is contained in:
parent
296d1bea6a
commit
e88a2445bc
4 changed files with 40 additions and 2 deletions
13
Lib/test/mp_fork_bomb.py
Normal file
13
Lib/test/mp_fork_bomb.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
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)
|
Loading…
Add table
Add a link
Reference in a new issue