Skip to content

Commit 3eeb725

Browse files
committed
Avoid subTest races in test_ssl_in_multiple_threads
1 parent 68fcb95 commit 3eeb725

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

Lib/test/test_ssl.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3016,20 +3016,13 @@ def test_ssl_in_multiple_threads(self):
30163016
self.test_wrong_cert_tls12,
30173017
self.test_wrong_cert_tls13,
30183018
):
3019-
# Be careful with the number of threads here.
3020-
# Too many can result in failing tests.
3021-
for num in range(5):
3022-
with self.subTest(func=func, num=num):
3023-
threads.append(Thread(target=func))
3019+
for _ in range(5):
3020+
threads.append(Thread(target=func))
30243021

30253022
with threading_helper.catch_threading_exception() as cm:
3026-
for thread in threads:
3027-
with self.subTest(thread=thread):
3028-
thread.start()
3023+
with threading_helper.start_threads(threads):
3024+
pass
30293025

3030-
for thread in threads:
3031-
with self.subTest(thread=thread):
3032-
thread.join()
30333026
if cm.exc_value is not None:
30343027
# Some threads can skip their test
30353028
if not isinstance(cm.exc_value, unittest.SkipTest):

0 commit comments

Comments
 (0)