| 2861 | p.join() |
| 2862 | |
| 2863 | def test_terminate(self): |
| 2864 | # Simulate slow tasks which take "forever" to complete |
| 2865 | sleep_time = support.LONG_TIMEOUT |
| 2866 | |
| 2867 | if self.TYPE == 'threads': |
| 2868 | # Thread pool workers can't be forced to quit, so if the first |
| 2869 | # task starts early enough, we will end up waiting for it. |
| 2870 | # Sleep for a shorter time, so the test doesn't block. |
| 2871 | sleep_time = 1 |
| 2872 | |
| 2873 | p = self.Pool(3) |
| 2874 | args = [sleep_time for i in range(10_000)] |
| 2875 | result = p.map_async(time.sleep, args, chunksize=1) |
| 2876 | time.sleep(0.2) # give some tasks a chance to start |
| 2877 | p.terminate() |
| 2878 | p.join() |
| 2879 | |
| 2880 | def test_empty_iterable(self): |
| 2881 | # See Issue 12157 |