From 4bc4fa3cb7a15566f89f0347b3022249a2092e5c Mon Sep 17 00:00:00 2001 From: "Kim, Young Soo" Date: Thu, 28 May 2020 13:51:35 +0900 Subject: [PATCH] Fix a python exception issue on using Sequence object of keras with MirroredStrategy --- tensorflow/python/keras/utils/data_utils.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tensorflow/python/keras/utils/data_utils.py b/tensorflow/python/keras/utils/data_utils.py index 6c0122cdf72..3456db013d3 100644 --- a/tensorflow/python/keras/utils/data_utils.py +++ b/tensorflow/python/keras/utils/data_utils.py @@ -886,15 +886,18 @@ class OrderedEnqueuer(SequenceEnqueuer): `(inputs, targets)` or `(inputs, targets, sample_weights)`. """ - try: - while self.is_running(): - inputs = self.queue.get(block=True).get() - self.queue.task_done() + while self.is_running(): + try: + inputs = self.queue.get(block=True, timeout=5).get() + if self.is_running(): + self.queue.task_done() if inputs is not None: yield inputs - except Exception: # pylint: disable=broad-except - self.stop() - six.reraise(*sys.exc_info()) + except queue.Empty: + pass + except Exception: # pylint: disable=broad-except + self.stop() + six.reraise(*sys.exc_info()) def init_pool_generator(gens, random_seed=None, id_queue=None):