summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_memoryview.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2025-05-23 17:23:47 (GMT)
committerGitHub <noreply@github.com>2025-05-23 17:23:47 (GMT)
commit6e605861751eb0f8cca3836e2eadd34faf6a7ad2 (patch)
tree617fac117c83c53a687b8c2912617dcb0ab450f4 /Lib/test/test_memoryview.py
parentadb0794692f3c4b711da09bd541fb8ce4faeb101 (diff)
downloadcpython-6e605861751eb0f8cca3836e2eadd34faf6a7ad2.zip
cpython-6e605861751eb0f8cca3836e2eadd34faf6a7ad2.tar.gz
cpython-6e605861751eb0f8cca3836e2eadd34faf6a7ad2.tar.bz2
[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 fc0c9c24121c1a62b25b79062286f976699b59e9) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_memoryview.py')
-rw-r--r--Lib/test/test_memoryview.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py
index 61b068c..64f440f 100644
--- a/Lib/test/test_memoryview.py
+++ b/Lib/test/test_memoryview.py
@@ -743,19 +743,21 @@ class RacingTest(unittest.TestCase):
from multiprocessing.managers import SharedMemoryManager
except ImportError:
self.skipTest("Test requires multiprocessing")
- from threading import Thread
+ from threading import Thread, Event
- n = 100
+ start = Event()
with SharedMemoryManager() as smm:
obj = smm.ShareableList(range(100))
- threads = []
- for _ in range(n):
- # Issue gh-127085, the `ShareableList.count` is just a convenient way to mess the `exports`
- # counter of `memoryview`, this issue has no direct relation with `ShareableList`.
- threads.append(Thread(target=obj.count, args=(1,)))
-
+ def test():
+ # Issue gh-127085, the `ShareableList.count` is just a
+ # convenient way to mess the `exports` counter of `memoryview`,
+ # this issue has no direct relation with `ShareableList`.
+ 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):
- pass
+ start.set()
del obj