From 41ab76e55baad03af2e57a160137b555b366812e Mon Sep 17 00:00:00 2001 From: Zeng Jinle <32832641+sneaxiy@users.noreply.github.com> Date: Tue, 2 Jul 2019 17:39:02 +0800 Subject: [PATCH] add friendly error msg to py_reader (#18316) --- python/paddle/fluid/layers/io.py | 2 ++ python/paddle/fluid/reader.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/python/paddle/fluid/layers/io.py b/python/paddle/fluid/layers/io.py index f819625e08b..249c15e4f15 100644 --- a/python/paddle/fluid/layers/io.py +++ b/python/paddle/fluid/layers/io.py @@ -28,6 +28,7 @@ from ..framework import convert_np_dtype_to_dtype_, default_main_program, \ default_startup_program, program_guard, Program, Variable from ..layer_helper import LayerHelper from ..unique_name import generate as unique_name +import logging __all__ = [ 'data', 'open_files', 'read_file', 'shuffle', 'batch', 'double_buffer', @@ -593,6 +594,7 @@ def _py_reader(capacity, feed_queue.close() except Exception as ex: feed_queue.close() + logging.warn('Your decorated reader has raised an exception!') raise ex reader.thread = threading.Thread(target=__provider_thread__) diff --git a/python/paddle/fluid/reader.py b/python/paddle/fluid/reader.py index 58b4af31fda..dd08920d2f6 100644 --- a/python/paddle/fluid/reader.py +++ b/python/paddle/fluid/reader.py @@ -23,6 +23,7 @@ from .executor import global_scope from .data_feeder import DataFeeder, BatchedTensorProvider, ListTensorProvider from .layers.io import monkey_patch_reader_methods, _copy_reader_var_, double_buffer from .unique_name import UniqueNameGenerator +import logging __all__ = ['PyReader'] @@ -441,6 +442,7 @@ class PyReader(object): self._queue.close() except Exception as ex: self._queue.close() + logging.warn('Your decorated reader has raised an exception!') raise ex self._thread = threading.Thread(target=__thread_main__) -- GitLab