From 9b64c590cca96f7538de41957f64478beee896b1 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 5 Feb 2019 16:20:31 -0500 Subject: [PATCH] curds: Switch to using the asyncio module for testing threading I'm planning to use the asyncio code for running background threads, so let's switch to it for now to get a feel for how it works. Signed-off-by: Anna Schumaker --- curds/test_album.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/curds/test_album.py b/curds/test_album.py index 893bb55..b812812 100644 --- a/curds/test_album.py +++ b/curds/test_album.py @@ -1,6 +1,7 @@ # Copyright 2019 (c) Anna Schumaker +import asyncio +import concurrent.futures import hashlib -from multiprocessing.pool import ThreadPool import unittest import album @@ -58,8 +59,8 @@ class TestAlbumClass(unittest.TestCase): def test_parallel_lookup(self): album.album_map.clear() - with ThreadPool(processes=5) as pool: - res = pool.map(album.lookup, [ album_info ] * 20) + with concurrent.futures.ThreadPoolExecutor(max_workers=5) as pool: + res = list(pool.map(album.lookup, [ album_info ] * 20)) self.assertIsNotNone(res[0]) self.assertEqual(res.count(res[0]), 20) self.assertEqual(len(album.album_map), 1)