diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-08-30 21:18:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-30 21:18:49 (GMT) |
commit | 320d398262349d4928031142339ad895a052e83c (patch) | |
tree | c8c77fe80db6f24e5791ee95a0e8936b275bcded /Lib/test/_test_multiprocessing.py | |
parent | 420db1027b7f8f1ff13bb62cc0579596e7116fd5 (diff) | |
download | cpython-320d398262349d4928031142339ad895a052e83c.zip cpython-320d398262349d4928031142339ad895a052e83c.tar.gz cpython-320d398262349d4928031142339ad895a052e83c.tar.bz2 |
[3.12] gh-108520: Fix bad fork detection in nested multiprocessing use case (GH-108568) (#108691)
gh-108520: Fix bad fork detection in nested multiprocessing use case (GH-108568)
gh-107275 introduced a regression where a SemLock would fail being passed along nested child processes, as the `is_fork_ctx` attribute would be left missing after the first deserialization.
---------
(cherry picked from commit add8d45cbe46581b9748909fbbf60fdc8ee8f71e)
Co-authored-by: albanD <desmaison.alban@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r-- | Lib/test/_test_multiprocessing.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index 19e1086..c1e18dd 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -5405,6 +5405,32 @@ class TestStartMethod(unittest.TestCase): p.start() p.join() + @classmethod + def _put_one_in_queue(cls, queue): + queue.put(1) + + @classmethod + def _put_two_and_nest_once(cls, queue): + queue.put(2) + process = multiprocessing.Process(target=cls._put_one_in_queue, args=(queue,)) + process.start() + process.join() + + def test_nested_startmethod(self): + # gh-108520: Regression test to ensure that child process can send its + # arguments to another process + queue = multiprocessing.Queue() + + process = multiprocessing.Process(target=self._put_two_and_nest_once, args=(queue,)) + process.start() + process.join() + + results = [] + while not queue.empty(): + results.append(queue.get()) + + self.assertEqual(results, [2, 1]) + @unittest.skipIf(sys.platform == "win32", "test semantics don't make sense on Windows") |