diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-09-23 17:40:06 +0000 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-09-24 09:44:56 +0000 |
| commit | ac4fc6e7c7d71c3f8e2440a8ed8095c5aab15dd8 (patch) | |
| tree | e143d6d261f22cb06f2c0d5b344a4353e5b3be1b /odoo/tools/misc.py | |
| parent | a6a3df3d0eda0fc2476c59de61d59534815f7c20 (diff) | |
| parent | bd3e510edbcd62f508dae28f573ee4d1a51bcf87 (diff) | |
[MERGE] forward port branch saas-12.3 up to bd3e510edbc
closes odoo/odoo#37314
Signed-off-by: Christophe Simonis <chs@odoo.com>
Diffstat (limited to 'odoo/tools/misc.py')
| -rw-r--r-- | odoo/tools/misc.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/odoo/tools/misc.py b/odoo/tools/misc.py index 44c3dd4bc41..a3832bef6c2 100644 --- a/odoo/tools/misc.py +++ b/odoo/tools/misc.py @@ -895,8 +895,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): @@ -913,14 +915,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 |
