(self)
| 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 |
nothing calls this directly
no test coverage detected