diff --git a/python/ray/tune/function_runner.py b/python/ray/tune/function_runner.py index e30e2bdf5..1e27915df 100644 --- a/python/ray/tune/function_runner.py +++ b/python/ray/tune/function_runner.py @@ -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