[3.12] gh-131677: Fix flaky test_lru_cache_threaded3 (gh-131679) (gh-131693)

The call to `with self.subTest(...)` was not thread-safe.
(cherry picked from commit a123245986)

Co-authored-by: Sam Gross <colesbury@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-03-24 21:59:03 +01:00 committed by GitHub
parent 76e911a040
commit e78280d0de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1756,8 +1756,7 @@ def f(x):
time.sleep(.01)
return 3 * x
def test(i, x):
with self.subTest(thread=i):
self.assertEqual(f(x), 3 * x, i)
self.assertEqual(f(x), 3 * x, i)
threads = [threading.Thread(target=test, args=(i, v))
for i, v in enumerate([1, 2, 2, 3, 2])]
with threading_helper.start_threads(threads):