diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-30 12:49:17 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-30 12:49:17 (GMT) |
commit | bf2b3b72d370f866aa5b8f9077ff37e7c53de894 (patch) | |
tree | 4472c6d6b49efb666ea98f0124afbfa225581d6e /Lib/test/test_functools.py | |
parent | 8b2e8b6cce4960e945c7c635c350c8e44a0f9022 (diff) | |
download | cpython-bf2b3b72d370f866aa5b8f9077ff37e7c53de894.zip cpython-bf2b3b72d370f866aa5b8f9077ff37e7c53de894.tar.gz cpython-bf2b3b72d370f866aa5b8f9077ff37e7c53de894.tar.bz2 |
Use test.support.start_threads() in threaded lru_cache tests.
Diffstat (limited to 'Lib/test/test_functools.py')
-rw-r--r-- | Lib/test/test_functools.py | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py index 271d655..e8cf848 100644 --- a/Lib/test/test_functools.py +++ b/Lib/test/test_functools.py @@ -1120,14 +1120,10 @@ class TestLRU: sys.setswitchinterval(1e-6) try: # create 5 threads in order to fill cache - threads = [] - for k in range(5): - t = threading.Thread(target=full, args=[f, k, k]) - t.start() - threads.append(t) - - for t in threads: - t.join() + threads = [threading.Thread(target=full, args=[f, k, k]) + for k in range(5)] + with support.start_threads(threads): + pass hits, misses, maxsize, currsize = f.cache_info() self.assertEqual(hits, 45) @@ -1135,16 +1131,11 @@ class TestLRU: self.assertEqual(currsize, 5) # create 5 threads in order to fill cache and 1 to clear it - cleaner = threading.Thread(target=clear, args=[f]) - cleaner.start() - threads = [cleaner] - for k in range(5): - t = threading.Thread(target=full, args=[f, k, k]) - t.start() - threads.append(t) - - for t in threads: - t.join() + threads = [threading.Thread(target=clear, args=[f])] + threads += [threading.Thread(target=full, args=[f, k, k]) + for k in range(5)] + with support.start_threads(threads): + pass finally: sys.setswitchinterval(orig_si) |