mirror of
https://github.com/python/cpython.git
synced 2025-10-25 10:44:55 +00:00
[3.14] gh-134381: Fix RuntimeError when starting not-yet started Thread after fork (gh-134514) (gh-134596)
(cherry picked from commit 9a2346df86)
Co-authored-by: Jiucheng(Oliver) <git.jiucheng@gmail.com>
This commit is contained in:
parent
6e60586175
commit
09a34f1f65
3 changed files with 29 additions and 0 deletions
|
|
@ -6832,6 +6832,28 @@ def f(x): return x*x
|
|||
self.assertEqual("332833500", out.decode('utf-8').strip())
|
||||
self.assertFalse(err, msg=err.decode('utf-8'))
|
||||
|
||||
def test_forked_thread_not_started(self):
|
||||
# gh-134381: Ensure that a thread that has not been started yet in
|
||||
# the parent process can be started within a forked child process.
|
||||
|
||||
if multiprocessing.get_start_method() != "fork":
|
||||
self.skipTest("fork specific test")
|
||||
|
||||
q = multiprocessing.Queue()
|
||||
t = threading.Thread(target=lambda: q.put("done"), daemon=True)
|
||||
|
||||
def child():
|
||||
t.start()
|
||||
t.join()
|
||||
|
||||
p = multiprocessing.Process(target=child)
|
||||
p.start()
|
||||
p.join(support.SHORT_TIMEOUT)
|
||||
|
||||
self.assertEqual(p.exitcode, 0)
|
||||
self.assertEqual(q.get_nowait(), "done")
|
||||
close_queue(q)
|
||||
|
||||
|
||||
#
|
||||
# Mixins
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue