def _run_batches_from_queue(self):
skip_batch = False
while not self._stop_flag:
future = self._prefetch_queue.get(block=True)
if future is None:
self._prefetch_queue.task_done()
self._batch_queue.put(None)
break
else:
try:
batch = future.result()
except SkipBatchException:
skip_batch = True
except Exception: # pylint: disable=broad-except
exc = future.exception()
print("Exception in a thread:", exc)
traceback.print_tb(exc.__traceback__)
finally:
if not skip_batch:
self._batch_queue.put(batch, block=True)
skip_batch = False
self._prefetch_queue.task_done()
return None
评论列表
文章目录