8000 gh-133454: Reduce the number of threads in test_racing_getbuf_and_rel… · python/cpython@fc0c9c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit fc0c9c2

Browse files
gh-133454: Reduce the number of threads in test_racing_getbuf_and_releasebuf (GH-133458)
The original reproducer only used 10 threads.
1 parent 71dea74 commit fc0c9c2

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Lib/test/test_memoryview.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -743,19 +743,21 @@ def test_racing_getbuf_and_releasebuf(self):
743743
from multiprocessing.managers import SharedMemoryManager
744744
except ImportError:
745745
self.skipTest("Test requires multiprocessing")
746-
from threading import Thread
746+
from threading import Thread, Event
747747

748-
n = 100
748+
start = Event()
749749
with SharedMemoryManager() as smm:
750750
obj = smm.ShareableList(range(100))
751-
threads = []
752-
for _ in range(n):
753-
# Issue gh-127085, the `ShareableList.count` is just a convenient way to mess the `exports`
754-
# counter of `memoryview`, this issue has no direct relation with `ShareableList`.
755-
threads.append(Thread(target=obj.count, args=(1,)))
756-
751+
def test():
752+
# Issue gh-127085, the `ShareableList.count` is just a
753+
# convenient way to mess the `exports` counter of `memoryview`,
754+
# this issue has no direct relation with `ShareableList`.
755+
start.wait(support.SHORT_TIMEOUT)
756+
for i in range(10):
757+
obj.count(1)
758+
threads = [Thread(target=test) for _ in range(10)]
757759
with threading_helper.start_threads(threads):
758-
pass
760+
start.set()
759761

760762
del obj
761763

0 commit comments

Comments
 (0)
0