|
2 | 2 | # to ensure the Queue locks remain stable. |
3 | 3 | import itertools |
4 | 4 | import random |
5 | | -import sys |
6 | 5 | import threading |
7 | 6 | import time |
8 | 7 | import unittest |
9 | 8 | import weakref |
10 | | -from test.support import gc_collect |
| 9 | +from test.support import gc_collect, bigmemtest |
11 | 10 | from test.support import import_helper |
12 | 11 | from test.support import threading_helper |
13 | 12 |
|
@@ -964,33 +963,33 @@ def test_order(self): |
964 | 963 | # One producer, one consumer => results appended in well-defined order |
965 | 964 | self.assertEqual(results, inputs) |
966 | 965 |
|
967 | | - def test_many_threads(self): |
| 966 | + @bigmemtest(size=50, memuse=100*2**20, dry_run=False) |
| 967 | + def test_many_threads(self, size): |
968 | 968 | # Test multiple concurrent put() and get() |
969 | | - N = 50 |
970 | 969 | q = self.q |
971 | 970 | inputs = list(range(10000)) |
972 | | - results = self.run_threads(N, q, inputs, self.feed, self.consume) |
| 971 | + results = self.run_threads(size, q, inputs, self.feed, self.consume) |
973 | 972 |
|
974 | 973 | # Multiple consumers without synchronization append the |
975 | 974 | # results in random order |
976 | 975 | self.assertEqual(sorted(results), inputs) |
977 | 976 |
|
978 | | - def test_many_threads_nonblock(self): |
| 977 | + @bigmemtest(size=50, memuse=100*2**20, dry_run=False) |
| 978 | + def test_many_threads_nonblock(self, size): |
979 | 979 | # Test multiple concurrent put() and get(block=False) |
980 | | - N = 50 |
981 | 980 | q = self.q |
982 | 981 | inputs = list(range(10000)) |
983 | | - results = self.run_threads(N, q, inputs, |
| 982 | + results = self.run_threads(size, q, inputs, |
984 | 983 | self.feed, self.consume_nonblock) |
985 | 984 |
|
986 | 985 | self.assertEqual(sorted(results), inputs) |
987 | 986 |
|
988 | | - def test_many_threads_timeout(self): |
| 987 | + @bigmemtest(size=50, memuse=100*2**20, dry_run=False) |
| 988 | + def test_many_threads_timeout(self, size): |
989 | 989 | # Test multiple concurrent put() and get(timeout=...) |
990 | | - N = 50 |
991 | 990 | q = self.q |
992 | 991 | inputs = list(range(1000)) |
993 | | - results = self.run_threads(N, q, inputs, |
| 992 | + results = self.run_threads(size, q, inputs, |
994 | 993 | self.feed, self.consume_timeout) |
995 | 994 |
|
996 | 995 | self.assertEqual(sorted(results), inputs) |
|
0 commit comments