From 127bc5ff91b0a1bf3879a5e1df4d03fb3bb38014 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Mon, 22 Jan 2018 19:21:48 +0100 Subject: improve error message if a task fails Change-Id: Ibaf8ec5fb060d3bdfa95ddb0fc034b657a0797d3 Reviewed-by: Eike Ziller Reviewed-by: Iikka Eklund --- packaging-tools/threadedwork.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'packaging-tools/threadedwork.py') diff --git a/packaging-tools/threadedwork.py b/packaging-tools/threadedwork.py index b632b5921..7ed56da6c 100644 --- a/packaging-tools/threadedwork.py +++ b/packaging-tools/threadedwork.py @@ -48,6 +48,7 @@ import itertools import multiprocessing import os import threading +import traceback import time import Queue as queue # The Queue module has been renamed to queue in Python 3. import sys @@ -127,6 +128,8 @@ class TaskFunction(): def __init__(self, function, *arguments): self.function = function self.arguments = arguments + def __str__(self): + return str(self.__dict__) class Task(): def __init__(self, description, function = None, *arguments): @@ -153,8 +156,10 @@ class Task(): with outputLock: # there is no clean exit so we adding linesep here sys.__stdout__.write(os.linesep) - sys.__stderr__.write(e.message) sys.__stdout__.flush() + sys.__stderr__.write(format(taskFunction)) + sys.__stderr__.write(os.linesep) + sys.__stderr__.write(traceback.format_exc()) sys.__stderr__.flush() self.exitFunction(*(self.exitFunctionArguments)) print("Done") -- cgit v1.2.3