diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-11-21 01:04:21 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-11-21 01:04:21 (GMT) |
commit | b9a4501179eec7762fcf3536833707f58d2474d2 (patch) | |
tree | 3bad8bed599dae83840223a687aaa98c70ef1895 /Lib | |
parent | 527d4ace8537a4db6dca65955a41470be4f07269 (diff) | |
download | cpython-b9a4501179eec7762fcf3536833707f58d2474d2.zip cpython-b9a4501179eec7762fcf3536833707f58d2474d2.tar.gz cpython-b9a4501179eec7762fcf3536833707f58d2474d2.tar.bz2 |
Issue #21963: backout issue #1856 patch (avoid crashes and lockups when
daemon threads run while the interpreter is shutting down; instead,
these threads are now killed when they try to take the GIL), as it seems
to break some existing code.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_threading.py | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index ac41f2d..00b8d19 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -700,49 +700,6 @@ class ThreadJoinOnShutdown(BaseTestCase): output = "end of worker thread\nend of main thread\n" self.assertScriptHasOutput(script, output) - @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") - def test_6_daemon_threads(self): - # Check that a daemon thread cannot crash the interpreter on shutdown - # by manipulating internal structures that are being disposed of in - # the main thread. - script = """if True: - import os - import random - import sys - import time - import threading - - thread_has_run = set() - - def random_io(): - '''Loop for a while sleeping random tiny amounts and doing some I/O.''' - while True: - in_f = open(os.__file__, 'rb') - stuff = in_f.read(200) - null_f = open(os.devnull, 'wb') - null_f.write(stuff) - time.sleep(random.random() / 1995) - null_f.close() - in_f.close() - thread_has_run.add(threading.current_thread()) - - def main(): - count = 0 - for _ in range(40): - new_thread = threading.Thread(target=random_io) - new_thread.daemon = True - new_thread.start() - count += 1 - while len(thread_has_run) < count: - time.sleep(0.001) - # Trigger process shutdown - sys.exit(0) - - main() - """ - rc, out, err = assert_python_ok('-c', script) - self.assertFalse(err) - @unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()") @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug") def test_reinit_tls_after_fork(self): |