X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=bin%2Fopenerp-server.py;h=8d210fc290646e0295724384e81c578cd1ec5014;hb=d0dee320199662492c3779deef06c412238eec73;hp=9061b0ae3c8a004d6b902adb608355908f343c61;hpb=c7fedc09fdeac8142731e88e3f9ded518b441886;p=odoo%2Fodoo.git diff --git a/bin/openerp-server.py b/bin/openerp-server.py index 9061b0a..8d210fc 100755 --- a/bin/openerp-server.py +++ b/bin/openerp-server.py @@ -35,7 +35,6 @@ GNU Public Licence. #---------------------------------------------------------- import logging import os -import pwd import signal import sys import threading @@ -45,11 +44,13 @@ import release __author__ = release.author __version__ = release.version -# We DON't log this using the standard logger, because we might mess -# with the logfile's permissions. Just do a quick exit here. -if pwd.getpwuid(os.getuid())[0] == 'root' : - sys.stderr.write("Attempted to run OpenERP server as root. This is not good, aborting.\n") - sys.exit(1) +if os.name == 'posix': + import pwd + # We DON't log this using the standard logger, because we might mess + # with the logfile's permissions. Just do a quick exit here. + if pwd.getpwuid(os.getuid())[0] == 'root' : + sys.stderr.write("Attempted to run OpenERP server as root. This is not good, aborting.\n") + sys.exit(1) #---------------------------------------------------------- # get logger @@ -182,8 +183,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 +193,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: @@ -214,7 +215,7 @@ def quit(): # to trigger _force_quit() in case some non-daemon threads won't exit cleanly. # threading.Thread.join() should not mask signals (at least in python 2.5) for thread in threading.enumerate(): - if thread != threading.currentThread() and not thread.daemon: + if thread != threading.currentThread() and not thread.isDaemon(): while thread.isAlive(): # need a busyloop here as thread.join() masks signals # and would present the forced shutdown