MCPcopy Index your code
hub / github.com/python/cpython / test_ssl_in_multiple_threads

Method test_ssl_in_multiple_threads

Lib/test/test_ssl.py:3151–3190  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3149
3150 @unittest.skipUnless(support.Py_GIL_DISABLED, "test is only useful if the GIL is disabled")
3151 def test_ssl_in_multiple_threads(self):
3152 # See GH-124984: OpenSSL is not thread safe.
3153 threads = []
3154
3155 warnings_filters = sys.flags.context_aware_warnings
3156 global USE_SAME_TEST_CONTEXT
3157 USE_SAME_TEST_CONTEXT = True
3158 try:
3159 for func in (
3160 self.test_echo,
3161 self.test_alpn_protocols,
3162 self.test_getpeercert,
3163 self.test_crl_check,
3164 functools.partial(
3165 self.test_check_hostname_idn,
3166 warnings_filters=warnings_filters,
3167 ),
3168 self.test_wrong_cert_tls12,
3169 self.test_wrong_cert_tls13,
3170 ):
3171 # Be careful with the number of threads here.
3172 # Too many can result in failing tests.
3173 for num in range(5):
3174 with self.subTest(func=func, num=num):
3175 threads.append(Thread(target=func))
3176
3177 with threading_helper.catch_threading_exception() as cm:
3178 for thread in threads:
3179 with self.subTest(thread=thread):
3180 thread.start()
3181
3182 for thread in threads:
3183 with self.subTest(thread=thread):
3184 thread.join()
3185 if cm.exc_value is not None:
3186 # Some threads can skip their test
3187 if not isinstance(cm.exc_value, unittest.SkipTest):
3188 raise cm.exc_value
3189 finally:
3190 USE_SAME_TEST_CONTEXT = False
3191
3192 def test_getpeercert(self):
3193 if support.verbose:

Callers

nothing calls this directly

Calls 6

ThreadClass · 0.90
partialMethod · 0.80
subTestMethod · 0.45
appendMethod · 0.45
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected