diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index 4b7c3e7fa8bdd7..4b7e6445e16930 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'', 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('', repr(lock)) - time.sleep(0.2) + t.join() + self.assertEqual('', repr(rlock)) pname = 'P1' l = multiprocessing.Manager().list() @@ -1539,14 +1536,11 @@ def test_repr_rlock(self): p.join() self.assertEqual(f'', 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('', repr(lock)) p.join() + self.assertEqual('', 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`.