diff options
| author | albanD <desmaison.alban@gmail.com> | 2023-08-30 17:07:41 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-30 17:07:41 (GMT) |
| commit | add8d45cbe46581b9748909fbbf60fdc8ee8f71e (patch) | |
| tree | eeaffda1c22e7c99be3c23a22d04d6e2866ebd5f /Lib/test/_test_multiprocessing.py | |
| parent | 2a3926fa51b7264787d5988abf083d8c4328f4ad (diff) | |
| download | cpython-add8d45cbe46581b9748909fbbf60fdc8ee8f71e.zip cpython-add8d45cbe46581b9748909fbbf60fdc8ee8f71e.tar.gz cpython-add8d45cbe46581b9748909fbbf60fdc8ee8f71e.tar.bz2 | |
gh-108520: Fix bad fork detection in nested multiprocessing use case (#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.
---------
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 343e9dc..7a851d3 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -5443,6 +5443,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") |
