(self)
| 116 | thread.stack_size(0) |
| 117 | |
| 118 | def test__count(self): |
| 119 | # Test the _count() function. |
| 120 | orig = thread._count() |
| 121 | mut = thread.allocate_lock() |
| 122 | mut.acquire() |
| 123 | started = [] |
| 124 | |
| 125 | def task(): |
| 126 | started.append(None) |
| 127 | mut.acquire() |
| 128 | mut.release() |
| 129 | |
| 130 | with threading_helper.wait_threads_exit(): |
| 131 | thread.start_new_thread(task, ()) |
| 132 | for _ in support.sleeping_retry(support.LONG_TIMEOUT): |
| 133 | if started: |
| 134 | break |
| 135 | self.assertEqual(thread._count(), orig + 1) |
| 136 | |
| 137 | # Allow the task to finish. |
| 138 | mut.release() |
| 139 | |
| 140 | # The only reliable way to be sure that the thread ended from the |
| 141 | # interpreter's point of view is to wait for the function object to |
| 142 | # be destroyed. |
| 143 | done = [] |
| 144 | wr = weakref.ref(task, lambda _: done.append(None)) |
| 145 | del task |
| 146 | |
| 147 | for _ in support.sleeping_retry(support.LONG_TIMEOUT): |
| 148 | if done: |
| 149 | break |
| 150 | support.gc_collect() # For PyPy or other GCs. |
| 151 | self.assertEqual(thread._count(), orig) |
| 152 | |
| 153 | def test_unraisable_exception(self): |
| 154 | def task(): |
nothing calls this directly
no test coverage detected