| 315 | raise NotImplementedError("DataLoaderIterator cannot be pickled") |
| 316 | |
| 317 | def _shutdown_workers(self): |
| 318 | try: |
| 319 | if not self.shutdown: |
| 320 | self.shutdown = True |
| 321 | self.done_event.set() |
| 322 | # if worker_manager_thread is waiting to put |
| 323 | while not self.data_queue.empty(): |
| 324 | self.data_queue.get() |
| 325 | for _ in self.workers: |
| 326 | self.index_queue.put(None) |
| 327 | # done_event should be sufficient to exit worker_manager_thread, |
| 328 | # but be safe here and put another None |
| 329 | self.worker_result_queue.put(None) |
| 330 | finally: |
| 331 | # removes pids no matter what |
| 332 | if self.worker_pids_set: |
| 333 | _remove_worker_pids(id(self)) |
| 334 | self.worker_pids_set = False |
| 335 | |
| 336 | def __del__(self): |
| 337 | if self.num_workers > 0: |