summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/_test_multiprocessing.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 8e4e076..6a050fa 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -2693,12 +2693,17 @@ class _TestPool(BaseTestCase):
p.join()
def test_terminate(self):
+ # Simulate slow tasks which take "forever" to complete
+ sleep_time = support.LONG_TIMEOUT
+
if self.TYPE == 'threads':
- self.skipTest("Threads cannot be terminated")
+ # Thread pool workers can't be forced to quit, so if the first
+ # task starts early enough, we will end up waiting for it.
+ # Sleep for a shorter time, so the test doesn't block.
+ sleep_time = 1
- # Simulate slow tasks which take "forever" to complete
p = self.Pool(3)
- args = [support.LONG_TIMEOUT for i in range(10_000)]
+ args = [sleep_time for i in range(10_000)]
result = p.map_async(time.sleep, args, chunksize=1)
p.terminate()
p.join()