#----------------------------------------------------------
import logging
import os
-import pwd
import signal
import sys
import threading
__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
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))
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: