annotate Lib/test/mp_fork_bomb.py @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents e4fe1daef9f7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
78561
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
1 import multiprocessing
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
2
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
3 def foo(conn):
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
4 conn.send("123")
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
5
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
6 # Because "if __name__ == '__main__'" is missing this will not work
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
7 # correctly on Windows. However, we should get a RuntimeError rather
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
8 # than the Windows equivalent of a fork bomb.
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
9
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
10 r, w = multiprocessing.Pipe(False)
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
11 p = multiprocessing.Process(target=foo, args=(w,))
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
12 p.start()
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
13 w.close()
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
14 print(r.recv())
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
15 r.close()
e4fe1daef9f7 Issue #15646: Prevent equivalent of a fork bomb when using multiprocessing
Richard Oudkerk <shibturn@gmail.com>
parents:
diff changeset
16 p.join()