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

Method test_join_from_self

Lib/test/test_thread.py:215–242  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

213 handle_destroyed.release()
214
215 def test_join_from_self(self):
216 errors = []
217 handles = []
218 start_joinable_thread_returned = thread.allocate_lock()
219 start_joinable_thread_returned.acquire()
220 task_tried_to_join = thread.allocate_lock()
221 task_tried_to_join.acquire()
222
223 def task():
224 start_joinable_thread_returned.acquire()
225 try:
226 handles[0].join()
227 except Exception as e:
228 errors.append(e)
229 finally:
230 task_tried_to_join.release()
231
232 with threading_helper.wait_threads_exit():
233 handle = thread.start_joinable_thread(task)
234 handles.append(handle)
235 start_joinable_thread_returned.release()
236 # Can still join after joining failed in other thread
237 task_tried_to_join.acquire()
238 handle.join()
239
240 assert len(errors) == 1
241 with self.assertRaisesRegex(RuntimeError, "Cannot join current thread"):
242 raise errors[0]
243
244 def test_join_then_self_join(self):
245 # make sure we can't deadlock in the following scenario with

Callers

nothing calls this directly

Calls 5

assertRaisesRegexMethod · 0.80
acquireMethod · 0.45
appendMethod · 0.45
releaseMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected