(self, q)
| 164 | q.task_done() |
| 165 | |
| 166 | def queue_join_test(self, q): |
| 167 | self.cum = 0 |
| 168 | threads = [] |
| 169 | for i in (0,1): |
| 170 | thread = threading.Thread(target=self.worker, args=(q,)) |
| 171 | thread.start() |
| 172 | threads.append(thread) |
| 173 | for i in range(100): |
| 174 | q.put(i) |
| 175 | q.join() |
| 176 | self.assertEqual(self.cum, sum(range(100)), |
| 177 | "q.join() did not block until all tasks were done") |
| 178 | for i in (0,1): |
| 179 | q.put(-1) # instruct the threads to close |
| 180 | q.join() # verify that you can join twice |
| 181 | for thread in threads: |
| 182 | thread.join() |
| 183 | |
| 184 | def test_queue_task_done(self): |
| 185 | # Test to make sure a queue task completed successfully. |
no test coverage detected