mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-129401: Test repr rlock failing randomly (#129959)
Fix and simplify a test of `test_repr_rlock` about multiprocessing.RLock primitive.
This commit is contained in:
parent
5326c27fc6
commit
a98a6bd112
2 changed files with 8 additions and 13 deletions
|
@ -1521,14 +1521,11 @@ class _TestLock(BaseTestCase):
|
|||
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 @@ class _TestLock(BaseTestCase):
|
|||
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()
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fix a flaky test in ``test_repr_rlock`` that checks the representation of :class:`multiprocessing.RLock`.
|
Loading…
Add table
Add a link
Reference in a new issue