[add] traceback for error in Thread
This commit is contained in:
parent
b3b3dca41a
commit
3c8ed2e44e
@ -67,9 +67,10 @@ class Thread(QThread):
|
||||
except Exception as e:
|
||||
self._executed = False
|
||||
self._executedError = e
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
|
||||
print('Exception: {}, file: {}, line: {}'.format(exc_type, fname, exc_tb.tb_lineno))
|
||||
traceback.print_exc()
|
||||
exctype, value = sys.exc_info ()[:2]
|
||||
self._executedErrorInfo = '{} {} {}'.\
|
||||
format(exctype, value, traceback.format_exc())
|
||||
sys.stdout = sys.__stdout__
|
||||
|
||||
def showProgressbar(self):
|
||||
@ -107,7 +108,7 @@ class Thread(QThread):
|
||||
|
||||
class Worker(QRunnable):
|
||||
'''
|
||||
|
||||
Worker class to be run by MultiThread(QThread).
|
||||
'''
|
||||
def __init__(self, fun, args,
|
||||
progressText=None,
|
||||
@ -130,7 +131,7 @@ class Worker(QRunnable):
|
||||
try:
|
||||
result = self.fun(self.args)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
#traceback.print_exc()
|
||||
exctype, value = sys.exc_info ()[:2]
|
||||
print(exctype, value, traceback.format_exc())
|
||||
#self.signals.error.emit ((exctype, value, traceback.format_exc ()))
|
||||
@ -148,6 +149,7 @@ class Worker(QRunnable):
|
||||
|
||||
class WorkerSignals(QObject):
|
||||
'''
|
||||
Class to provide signals for Worker Class
|
||||
'''
|
||||
finished = Signal(str)
|
||||
message = Signal(str)
|
||||
|
@ -2342,8 +2342,10 @@ class TuneAutopicker(QWidget):
|
||||
def finish_picker(self):
|
||||
self.enable(True)
|
||||
if not self.ap_thread._executed:
|
||||
self._warn('Could not execute picker:\n{}'.format(
|
||||
self.ap_thread._executedError))
|
||||
msg = 'Could not execute picker:\n{}'.format(
|
||||
self.ap_thread._executedError)
|
||||
info = self.ap_thread._executedErrorInfo
|
||||
self._warn(msg, info)
|
||||
return
|
||||
self.pylot_picks = self.ap_thread.data
|
||||
if not self.pylot_picks:
|
||||
@ -2396,9 +2398,10 @@ class TuneAutopicker(QWidget):
|
||||
self.figure_tabs.setTabEnabled(2, bool)
|
||||
self.figure_tabs.setTabEnabled(3, bool)
|
||||
|
||||
def _warn(self, message):
|
||||
def _warn(self, message, info=None):
|
||||
self.qmb = QtGui.QMessageBox(QtGui.QMessageBox.Icon.Warning,
|
||||
'Warning', message)
|
||||
self.qmb.setDetailedText(str(info))
|
||||
self.qmb.show()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user