summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_threading.py
diff options
context:
space:
mode:
authorCharles-François Natali <neologix@free.fr>2012-02-02 19:38:10 (GMT)
committerCharles-François Natali <neologix@free.fr>2012-02-02 19:38:10 (GMT)
commit3f32fc87adfa5e14ee24c8dc94e629e74283d1ca (patch)
tree23f3c9cf35f01d95bd5b16e7f72a15f7afa11108 /Lib/test/test_threading.py
parent4b0eab62f04fc2e738b1bff1d170c7f6f96c1920 (diff)
parent227e377b36378d4cc86c3dd182f8d7c031e41f86 (diff)
downloadcpython-3f32fc87adfa5e14ee24c8dc94e629e74283d1ca.zip
cpython-3f32fc87adfa5e14ee24c8dc94e629e74283d1ca.tar.gz
cpython-3f32fc87adfa5e14ee24c8dc94e629e74283d1ca.tar.bz2
Merge.
Diffstat (limited to 'Lib/test/test_threading.py')
-rw-r--r--Lib/test/test_threading.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index de29afa..77c4ca4 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -674,6 +674,29 @@ class ThreadJoinOnShutdown(BaseTestCase):
rc, out, err = assert_python_ok('-c', script)
self.assertFalse(err)
+ @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
+ def test_reinit_tls_after_fork(self):
+ # Issue #13817: fork() would deadlock in a multithreaded program with
+ # the ad-hoc TLS implementation.
+
+ def do_fork_and_wait():
+ # just fork a child process and wait it
+ pid = os.fork()
+ if pid > 0:
+ os.waitpid(pid, 0)
+ else:
+ os._exit(0)
+
+ # start a bunch of threads that will fork() child processes
+ threads = []
+ for i in range(16):
+ t = threading.Thread(target=do_fork_and_wait)
+ threads.append(t)
+ t.start()
+
+ for t in threads:
+ t.join()
+
class ThreadingExceptionTests(BaseTestCase):
# A RuntimeError should be raised if Thread.start() is called