[FIX] openerp-server.py: python 2.5 compatibility for thread dump

bzr revid: odo@openerp.com-20100924125615-acisxmznw9y8b3bk
This commit is contained in:
Olivier Dony 2010-09-24 14:56:15 +02:00
parent 8e4b9e6875
commit f49b3ea722
1 changed files with 3 additions and 3 deletions

View File

@ -182,8 +182,9 @@ def handler(signum, frame):
def dumpstacks(signum, frame):
# code from http://stackoverflow.com/questions/132058/getting-stack-trace-from-a-running-python-application#answer-2569696
id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
# 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()])
code = []
for threadId, stack in sys._current_frames().items():
code.append("\n# Thread: %s(%d)" % (id2name[threadId], threadId))
@ -191,7 +192,6 @@ def dumpstacks(signum, frame):
code.append('File: "%s", line %d, in %s' % (filename, lineno, name))
if line:
code.append(" %s" % (line.strip()))
logging.getLogger('dumpstacks').info("\n".join(code))
for signum in SIGNALS: