https://github.com/python/cpython/commit/bb1247d83c14d24dc80fbec035e3c3e844a683b1 commit: bb1247d83c14d24dc80fbec035e3c3e844a683b1 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: colesbury <[email protected]> date: 2026-02-02T14:11:03-05:00 summary:
[3.13] gh-129401: Test repr rlock failing randomly (GH-129959) (#144405) Fix and simplify a test of `test_repr_rlock` about multiprocessing.RLock primitive. (cherry picked from commit a98a6bd1128663fbe58c0c73d468710245a57ad6) Co-authored-by: Duprat <[email protected]> files: A Misc/NEWS.d/next/Tests/2025-02-10-14-34-29.gh-issue-129401.Cq6Ruy.rst M Lib/test/_test_multiprocessing.py diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index 35a6f0830d472f..ded7c5249e155c 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -1484,14 +1484,11 @@ def test_repr_rlock(self): for i in range(n): self.assertIn(f'<RLock(MainProcess|T{i+1}, {i+1})>', l) - - t = threading.Thread(target=self._acquire_release, - args=(lock, 0.2), - name=f'T1') + rlock = self.RLock() + t = threading.Thread(target=rlock.acquire) t.start() - time.sleep(0.1) - self.assertEqual('<RLock(SomeOtherThread, nonzero)>', repr(lock)) - time.sleep(0.2) + t.join() + self.assertEqual('<RLock(SomeOtherThread, nonzero)>', repr(rlock)) pname = 'P1' l = multiprocessing.Manager().list() @@ -1502,14 +1499,11 @@ def test_repr_rlock(self): p.join() self.assertEqual(f'<RLock({pname}, 1)>', l[0]) - event = self.Event() - lock = self.RLock() - p = self.Process(target=self._acquire_event, - args=(lock, event)) + rlock = self.RLock() + p = self.Process(target=self._acquire, args=(rlock,)) p.start() - event.wait() - self.assertEqual('<RLock(SomeOtherProcess, nonzero)>', repr(lock)) p.join() + self.assertEqual('<RLock(SomeOtherProcess, nonzero)>', repr(rlock)) def test_rlock(self): lock = self.RLock() diff --git a/Misc/NEWS.d/next/Tests/2025-02-10-14-34-29.gh-issue-129401.Cq6Ruy.rst b/Misc/NEWS.d/next/Tests/2025-02-10-14-34-29.gh-issue-129401.Cq6Ruy.rst new file mode 100644 index 00000000000000..7b87d5455c1a70 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2025-02-10-14-34-29.gh-issue-129401.Cq6Ruy.rst @@ -0,0 +1 @@ +Fix a flaky test in ``test_repr_rlock`` that checks the representation of :class:`multiprocessing.RLock`. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
