summaryrefslogtreecommitdiff
path: root/odoo/tools/misc.py
diff options
context:
space:
mode:
authorDenis Vermylen <dve@odoo.com>2019-09-19 07:36:36 +0000
committerfw-bot <otis@odoo.com>2019-09-23 14:16:04 +0000
commitbd3e510edbcd62f508dae28f573ee4d1a51bcf87 (patch)
treeb7225c214ff715d2ef19f99f629a1ec2616eec96 /odoo/tools/misc.py
parentc987515c9fd192d365bffb3bc3c3e8bdfe466645 (diff)
[IMP] odoo: dump stacktrace of timed out threaded workers
So the logs contain some indication as to what was exceeding the limits. closes odoo/odoo#37303 X-original-commit: 0a266f444a0abda026d09ad88024dca1c50c92b9 Signed-off-by: Denis Vermylen <Icallhimtest@users.noreply.github.com>
Diffstat (limited to 'odoo/tools/misc.py')
-rw-r--r--odoo/tools/misc.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/odoo/tools/misc.py b/odoo/tools/misc.py
index a551d8d829b..e8bf26b4af3 100644
--- a/odoo/tools/misc.py
+++ b/odoo/tools/misc.py
@@ -909,8 +909,10 @@ class ConstantMapping(Mapping):
return self._value
-def dumpstacks(sig=None, frame=None):
- """ Signal handler: dump a stack trace for each existing thread."""
+def dumpstacks(sig=None, frame=None, thread_idents=None):
+ """ Signal handler: dump a stack trace for each existing thread or given
+ thread(s) specified through the ``thread_idents`` sequence.
+ """
code = []
def extract_stack(stack):
@@ -927,14 +929,15 @@ def dumpstacks(sig=None, frame=None):
'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 (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')))
- for line in extract_stack(stack):
- code.append(line)
+ if not thread_idents or threadId in thread_idents:
+ thread_info = threads_info.get(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')))
+ for line in extract_stack(stack):
+ code.append(line)
if odoo.evented:
# code from http://stackoverflow.com/questions/12510648/in-gevent-how-can-i-dump-stack-traces-of-all-running-greenlets