https://github.com/python/cpython/commit/a98a6bd1128663fbe58c0c73d468710245a57ad6 commit: a98a6bd1128663fbe58c0c73d468710245a57ad6 branch: main author: Duprat <ydup...@gmail.com> committer: colesbury <colesb...@gmail.com> date: 2025-03-01T15:28:14-05:00 summary:
gh-129401: Test repr rlock failing randomly (#129959) Fix and simplify a test of `test_repr_rlock` about multiprocessing.RLock primitive. 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 5dd89bd5af7daa..cafbc757904f64 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -1521,14 +1521,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() @@ -1539,14 +1536,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 -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com