提交 d7dbbeb3 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!116 log exception raised by new thread to help debugging

Merge pull request !116 from wenkai/wk_0515
......@@ -759,17 +759,17 @@ class DataManager:
self._reload_interval = reload_interval
self._max_threads_count = max_threads_count
thread = threading.Thread(target=self._reload_data,
thread = threading.Thread(target=self._reload_data_in_thread,
name='start_load_data_thread')
thread.daemon = True
thread.start()
def _reload_data(self):
def _reload_data_in_thread(self):
"""This function periodically loads the data."""
# Let gunicorn load other modules first.
time.sleep(1)
while True:
self._load_data()
self._load_data_in_thread()
if not self._reload_interval:
break
......@@ -782,11 +782,19 @@ class DataManager:
This function needs to be used after `start_load_data` function.
"""
logger.debug("start to reload data")
thread = threading.Thread(target=self._load_data,
thread = threading.Thread(target=self._load_data_in_thread,
name='reload_data_thread')
thread.daemon = False
thread.start()
def _load_data_in_thread(self):
"""Log (but not swallow) exceptions in thread to help debugging."""
try:
self._load_data()
except Exception as exc:
logger.exception(exc)
raise
def _load_data(self):
"""This function will load data once and ignore it if the status is loading."""
logger.info("Start to load data, reload interval: %r.", self._reload_interval)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册