From be59d0b85c07f797f478e45ff58c9b10527f6de1 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 25 Sep 2017 11:22:09 +0200 Subject: [PATCH] [IMP] tools.dumpstack: show extra thread info By using the thread's repr() we get its type, name, daemon status and ID, all at one time. No need to include them separately. Fall back to the threadId in case the repr() is empty, which can happen for exotic threads (the gevent main thread seems to be like that) --- odoo/tools/misc.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/odoo/tools/misc.py b/odoo/tools/misc.py index 9eabfd13bd9..7e796831f29 100644 --- a/odoo/tools/misc.py +++ b/odoo/tools/misc.py @@ -904,16 +904,15 @@ def dumpstacks(sig=None, frame=None): # code from http://stackoverflow.com/questions/132058/getting-stack-trace-from-a-running-python-application#answer-2569696 # modified for python 2.5 compatibility - threads_info = {th.ident: {'name': th.name, + threads_info = {th.ident: {'repr': repr(th), 'uid': getattr(th, 'uid', 'n/a'), 'dbname': getattr(th, 'dbname', 'n/a'), 'url': getattr(th, 'url', 'n/a')} for th in threading.enumerate()} for threadId, stack in sys._current_frames().items(): thread_info = threads_info.get(threadId, {}) - code.append("\n# Thread: %s (id:%s) (db:%s) (uid:%s) (url:%s)" % - (thread_info.get('name', 'n/a'), - threadId, + code.append("\n# Thread: %s (db:%s) (uid:%s) (url:%s)" % + (thread_info.get('repr', threadId), thread_info.get('dbname', 'n/a'), thread_info.get('uid', 'n/a'), thread_info.get('url', 'n/a')))