[3.14] gh-133454: Reduce the number of threads in test_racing_getbuf_and_releasebuf (GH-133458) (GH-134589)

The original reproducer only used 10 threads.
(cherry picked from commit fc0c9c2412)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-05-23 19:23:47 +02:00 committed by GitHub
parent adb0794692
commit 6e60586175
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -743,19 +743,21 @@ class RacingTest(unittest.TestCase):
from multiprocessing.managers import SharedMemoryManager from multiprocessing.managers import SharedMemoryManager
except ImportError: except ImportError:
self.skipTest("Test requires multiprocessing") self.skipTest("Test requires multiprocessing")
from threading import Thread from threading import Thread, Event
n = 100 start = Event()
with SharedMemoryManager() as smm: with SharedMemoryManager() as smm:
obj = smm.ShareableList(range(100)) obj = smm.ShareableList(range(100))
threads = [] def test():
for _ in range(n): # Issue gh-127085, the `ShareableList.count` is just a
# Issue gh-127085, the `ShareableList.count` is just a convenient way to mess the `exports` # convenient way to mess the `exports` counter of `memoryview`,
# counter of `memoryview`, this issue has no direct relation with `ShareableList`. # this issue has no direct relation with `ShareableList`.
threads.append(Thread(target=obj.count, args=(1,))) start.wait(support.SHORT_TIMEOUT)
for i in range(10):
obj.count(1)
threads = [Thread(target=test) for _ in range(10)]
with threading_helper.start_threads(threads): with threading_helper.start_threads(threads):
pass start.set()
del obj del obj