From 4af38cc64a07179a78b34d9cee55583714f106a0 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 16 Mar 2012 12:12:18 +0100 Subject: [PATCH] [IMP] attempt to dump uid performing operation along with thread stacks bzr revid: odo@openerp.com-20120316111218-o963t7xm4r4honoy --- openerp-server | 11 ++++++++--- openerp/netsvc.py | 2 ++ openerp/service/web_services.py | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/openerp-server b/openerp-server index f574ebb354f..12b6962e4e6 100755 --- a/openerp-server +++ b/openerp-server @@ -165,11 +165,16 @@ def dumpstacks(sig, frame): """ Signal handler: dump a stack trace for each existing thread.""" # code from http://stackoverflow.com/questions/132058/getting-stack-trace-from-a-running-python-application#answer-2569696 # modified for python 2.5 compatibility - thread_map = dict(threading._active, **threading._limbo) - id2name = dict([(threadId, thread.getName()) for threadId, thread in thread_map.items()]) + threads_info = dict([(th.ident, {'name': th.name, + 'uid': getattr(th,'uid','n/a')}) + for th in threading.enumerate()]) code = [] for threadId, stack in sys._current_frames().items(): - code.append("\n# Thread: %s(%d)" % (id2name.get(threadId,'n/a'), threadId)) + thread_info = threads_info.get(threadId) + code.append("\n# Thread: %s (id:%s) (uid:%s)" % \ + (thread_info and thread_info['name'] or 'n/a', + threadId, + thread_info and thread_info['uid'] or 'n/a')) for filename, lineno, name, line in traceback.extract_stack(stack): code.append('File: "%s", line %d, in %s' % (filename, lineno, name)) if line: diff --git a/openerp/netsvc.py b/openerp/netsvc.py index 0051fe6dea7..506c1e4bcba 100644 --- a/openerp/netsvc.py +++ b/openerp/netsvc.py @@ -357,6 +357,8 @@ def dispatch_rpc(service_name, method, params): if rpc_request and rpc_response_flag: log(rpc_request,logging.DEBUG,'%s.%s'%(service_name,method), replace_request_password(params)) + threading.current_thread().uid = None + threading.current_thread().dbname = None result = ExportService.getService(service_name).dispatch(method, params) if rpc_request_flag or rpc_response_flag: diff --git a/openerp/service/web_services.py b/openerp/service/web_services.py index a7136e24269..46beaecd323 100644 --- a/openerp/service/web_services.py +++ b/openerp/service/web_services.py @@ -561,6 +561,7 @@ class objects_proxy(netsvc.ExportService): def dispatch(self, method, params): (db, uid, passwd ) = params[0:3] + threading.current_thread().uid = uid params = params[3:] if method == 'obj_list': raise NameError("obj_list has been discontinued via RPC as of 6.0, please query ir.model directly!") @@ -594,6 +595,7 @@ class wizard(netsvc.ExportService): def dispatch(self, method, params): (db, uid, passwd ) = params[0:3] + threading.current_thread().uid = uid params = params[3:] if method not in ['execute','create']: raise KeyError("Method not supported %s" % method) @@ -645,6 +647,7 @@ class report_spool(netsvc.ExportService): def dispatch(self, method, params): (db, uid, passwd ) = params[0:3] + threading.current_thread().uid = uid params = params[3:] if method not in ['report', 'report_get', 'render_report']: raise KeyError("Method not supported %s" % method)