Files
cpython/Lib/test/test_free_threading/test_threading.py
T
8c5008060f [3.15] gh-153292: Fix data race in threading.RLock.__repr__ in FT builds (GH-153299) (#153314)
gh-153292: Fix data race in `threading.RLock.__repr__` in FT builds (GH-153299)
(cherry picked from commit 1051384fcd)

Co-authored-by: sobolevn <[email protected]>
2026-07-08 10:13:44 +00:00

27 lines
583 B
Python

import unittest
from test.support import threading_helper
threading_helper.requires_working_threading(module=True)
class TestRlock(unittest.TestCase):
def test_repr_race(self):
# gh-153292
import _thread
r = _thread.RLock()
def repr_thread():
for _ in range(2000):
repr(r)
def mutate_thread():
for _ in range(2000):
r.acquire()
r.release()
threading_helper.run_concurrently([repr_thread, mutate_thread])
if __name__ == "__main__":
unittest.main()