Browse Source

!116 log exception raised by new thread to help debugging

Merge pull request !116 from wenkai/wk_0515
tags/v0.3.0-alpha
mindspore-ci-bot Gitee 5 years ago
parent
commit
d7dbbeb3a3
1 changed files with 12 additions and 4 deletions
  1. +12
    -4
      mindinsight/datavisual/data_transform/data_manager.py

+ 12
- 4
mindinsight/datavisual/data_transform/data_manager.py View File

@@ -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)


Loading…
Cancel
Save