Skip to content

gh-113205: test_multiprocessing.test_terminate: Test the API on threadpools #114186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2693,12 +2693,17 @@ def test_make_pool(self):
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()
Expand Down