Fix a python exception issue on using Sequence object of keras with MirroredStrategy

This commit is contained in:
Kim, Young Soo 2020-05-28 13:51:35 +09:00
parent dedac5053f
commit 4bc4fa3cb7
1 changed files with 10 additions and 7 deletions

View File

@ -886,12 +886,15 @@ class OrderedEnqueuer(SequenceEnqueuer):
`(inputs, targets)` or `(inputs, targets)` or
`(inputs, targets, sample_weights)`. `(inputs, targets, sample_weights)`.
""" """
try:
while self.is_running(): while self.is_running():
inputs = self.queue.get(block=True).get() try:
inputs = self.queue.get(block=True, timeout=5).get()
if self.is_running():
self.queue.task_done() self.queue.task_done()
if inputs is not None: if inputs is not None:
yield inputs yield inputs
except queue.Empty:
pass
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
self.stop() self.stop()
six.reraise(*sys.exc_info()) six.reraise(*sys.exc_info())