Added failed thread group stacktrace to logs
Stacktrace will be printed as text, but this is better than having no stacktrace. Change-Id: Icbf1affe857a34b65efb76f282573d234b5c68f9 Closes-Bug: #1465398
This commit is contained in:
parent
4f61269415
commit
260201c8b7
@ -13,6 +13,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import traceback
|
||||
|
||||
import eventlet
|
||||
from eventlet.green import threading
|
||||
from eventlet.green import time
|
||||
@ -199,6 +201,7 @@ def _wrapper(ctx, thread_description, thread_group, func, *args, **kwargs):
|
||||
thread=thread_description, exception=e))
|
||||
if thread_group and not thread_group.exc:
|
||||
thread_group.exc = e
|
||||
thread_group.exc_stacktrace = traceback.format_exc()
|
||||
thread_group.failed_thread = thread_description
|
||||
finally:
|
||||
if thread_group:
|
||||
@ -224,6 +227,7 @@ class ThreadGroup(object):
|
||||
def __init__(self, thread_pool_size=1000):
|
||||
self.tg = greenpool.GreenPool(size=thread_pool_size)
|
||||
self.exc = None
|
||||
self.exc_stacktrace = None
|
||||
self.failed_thread = None
|
||||
self.threads = 0
|
||||
self.cv = threading.Condition()
|
||||
@ -256,7 +260,8 @@ class ThreadGroup(object):
|
||||
self.cv.wait()
|
||||
|
||||
if self.exc:
|
||||
raise ex.ThreadException(self.failed_thread, self.exc)
|
||||
raise ex.ThreadException(self.failed_thread, self.exc,
|
||||
self.exc_stacktrace)
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
@ -193,12 +193,14 @@ class DataTooBigException(SaharaException):
|
||||
|
||||
class ThreadException(SaharaException):
|
||||
code = "THREAD_EXCEPTION"
|
||||
message_template = _("An error occurred in thread '%(thread)s': %(e)s")
|
||||
message_template = _("An error occurred in thread '%(thread)s': %(e)s"
|
||||
"\n%(stacktrace)s")
|
||||
|
||||
def __init__(self, thread_description, e):
|
||||
def __init__(self, thread_description, e, stacktrace):
|
||||
formatted_message = self.message_template % {
|
||||
'thread': thread_description,
|
||||
'e': six.text_type(e)}
|
||||
'e': six.text_type(e),
|
||||
'stacktrace': stacktrace}
|
||||
|
||||
super(ThreadException, self).__init__(formatted_message)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user