Show conversion log on exceptions

This commit is contained in:
Kovid Goyal 2018-06-30 08:37:36 +05:30
parent 143bc34a1c
commit eda257421f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 8 additions and 2 deletions

View File

@ -45,6 +45,7 @@ class Job(Thread):
except WorkerError as err:
import traceback
self.traceback = err.orig_tb or traceback.format_exc()
self.log_path = getattr(err, 'log_path', None)
else:
self.result, self.log_path = result['result'], result['stdout_stderr']
self.done = True

View File

@ -20,9 +20,10 @@ from calibre.utils.ipc.launch import Worker
class WorkerError(Exception):
def __init__(self, msg, orig_tb=''):
def __init__(self, msg, orig_tb='', log_path=None):
Exception.__init__(self, msg)
self.orig_tb = orig_tb
self.log_path = log_path
class ConnectedWorker(Thread):
@ -225,6 +226,10 @@ def fork_job(mod_name, func_name, args=(), kwargs={}, timeout=300, # seconds
communicate(ans, w, listener, (mod_name, func_name, args, kwargs,
module_is_source_code), timeout=timeout, heartbeat=heartbeat,
abort=abort)
except WorkerError as e:
if not no_output:
e.log_path = w.log_path
raise
finally:
t = Thread(target=w.kill)
t.daemon=True

View File

@ -92,7 +92,7 @@ def show_failure(response):
if response.traceback:
log += response.traceback
if response.log:
log += '\n\n' + _('Conversion log')
log += '\n\n' + _('Conversion log') + '\n\n'
log += response.log
c.appendChild(E.pre(log))