[tune] Use traceback.format_tb() (fixes #5135) (#5136)

This commit is contained in:
Sam Toyer
2019-07-08 01:13:06 -07:00
committed by Richard Liaw
parent 274233962f
commit 7ad854d4c6
+6 -12
View File
@@ -3,10 +3,10 @@ from __future__ import division
from __future__ import print_function
import logging
import sys
import time
import inspect
import threading
import traceback
from six.moves import queue
from ray.tune import track
@@ -100,12 +100,9 @@ class _RunnerThread(threading.Thread):
# report the error but avoid indefinite blocking which would
# prevent the exception from being propagated in the unlikely
# case that something went terribly wrong
err_type, err_value, err_tb = sys.exc_info()
err_tb = err_tb.format_exc()
err_tb_str = traceback.format_exc()
self._error_queue.put(
(err_type, err_value, err_tb),
block=True,
timeout=ERROR_REPORT_TIMEOUT)
err_tb_str, block=True, timeout=ERROR_REPORT_TIMEOUT)
except queue.Full:
logger.critical(
("Runner Thread was unable to report error to main "
@@ -234,13 +231,10 @@ class FunctionRunner(Trainable):
def _report_thread_runner_error(self, block=False):
try:
err_type, err_value, err_tb = self._error_queue.get(
err_tb_str = self._error_queue.get(
block=block, timeout=ERROR_FETCH_TIMEOUT)
raise TuneError(("Trial raised a {err_type} exception with value: "
"{err_value}\nWith traceback:\n{err_tb}").format(
err_type=err_type,
err_value=err_value,
err_tb=err_tb))
raise TuneError(("Trial raised an exception. Traceback:\n{}"
.format(err_tb_str)))
except queue.Empty:
pass