""" 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:
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:
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!")
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)
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)