提交 41ab76e5 编写于 作者: Z Zeng Jinle 提交者: Tao Luo

add friendly error msg to py_reader (#18316)

上级 823ab5e8
...@@ -28,6 +28,7 @@ from ..framework import convert_np_dtype_to_dtype_, default_main_program, \ ...@@ -28,6 +28,7 @@ from ..framework import convert_np_dtype_to_dtype_, default_main_program, \
default_startup_program, program_guard, Program, Variable default_startup_program, program_guard, Program, Variable
from ..layer_helper import LayerHelper from ..layer_helper import LayerHelper
from ..unique_name import generate as unique_name from ..unique_name import generate as unique_name
import logging
__all__ = [ __all__ = [
'data', 'open_files', 'read_file', 'shuffle', 'batch', 'double_buffer', 'data', 'open_files', 'read_file', 'shuffle', 'batch', 'double_buffer',
...@@ -593,6 +594,7 @@ def _py_reader(capacity, ...@@ -593,6 +594,7 @@ def _py_reader(capacity,
feed_queue.close() feed_queue.close()
except Exception as ex: except Exception as ex:
feed_queue.close() feed_queue.close()
logging.warn('Your decorated reader has raised an exception!')
raise ex raise ex
reader.thread = threading.Thread(target=__provider_thread__) reader.thread = threading.Thread(target=__provider_thread__)
......
...@@ -23,6 +23,7 @@ from .executor import global_scope ...@@ -23,6 +23,7 @@ from .executor import global_scope
from .data_feeder import DataFeeder, BatchedTensorProvider, ListTensorProvider from .data_feeder import DataFeeder, BatchedTensorProvider, ListTensorProvider
from .layers.io import monkey_patch_reader_methods, _copy_reader_var_, double_buffer from .layers.io import monkey_patch_reader_methods, _copy_reader_var_, double_buffer
from .unique_name import UniqueNameGenerator from .unique_name import UniqueNameGenerator
import logging
__all__ = ['PyReader'] __all__ = ['PyReader']
...@@ -441,6 +442,7 @@ class PyReader(object): ...@@ -441,6 +442,7 @@ class PyReader(object):
self._queue.close() self._queue.close()
except Exception as ex: except Exception as ex:
self._queue.close() self._queue.close()
logging.warn('Your decorated reader has raised an exception!')
raise ex raise ex
self._thread = threading.Thread(target=__thread_main__) self._thread = threading.Thread(target=__thread_main__)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册