diff --git a/bin/addons/base/res/ir_property.py b/bin/addons/base/res/ir_property.py index 27a3223f18c..27536ff80f5 100644 --- a/bin/addons/base/res/ir_property.py +++ b/bin/addons/base/res/ir_property.py @@ -20,8 +20,9 @@ ############################################################################## from osv import osv,fields -from operator import attrgetter +from tools.misc import attrgetter import time + # ------------------------------------------------------------------------- # Properties # ------------------------------------------------------------------------- diff --git a/bin/addons/base/test/bug_lp541545.xml b/bin/addons/base/test/bug_lp541545.xml index 4c1df7a0383..79c3c05c729 100644 --- a/bin/addons/base/test/bug_lp541545.xml +++ b/bin/addons/base/test/bug_lp541545.xml @@ -5,7 +5,7 @@ diff --git a/bin/addons/base/test/test_context.xml b/bin/addons/base/test/test_context.xml index d6c6fa0afed..44751644403 100644 --- a/bin/addons/base/test/test_context.xml +++ b/bin/addons/base/test/test_context.xml @@ -6,15 +6,15 @@ ---> + - + - 58.8287 + 59.9739 diff --git a/bin/netsvc.py b/bin/netsvc.py index ca81372a8fe..e5a60f9d3ae 100644 --- a/bin/netsvc.py +++ b/bin/netsvc.py @@ -350,7 +350,7 @@ class Agent(object): delattr(current_thread, 'dbname') task_thread = threading.Thread(target=function, name='netsvc.Agent.task', args=args, kwargs=kwargs) # force non-daemon task threads (the runner thread must be daemon, and this property is inherited by default) - task_thread.daemon = False + task_thread.setDaemon(False) task_thread.start() time.sleep(1) time.sleep(60) @@ -359,7 +359,7 @@ agent_runner = threading.Thread(target=Agent.runner, name="netsvc.Agent.runner") # the agent runner is a typical daemon thread, that will never quit and must be # terminated when the main process exits - with no consequence (the processing # threads it spawns are not marked daemon) -agent_runner.daemon = True +agent_runner.setDaemon(True) agent_runner.start() diff --git a/bin/openerp-server.py b/bin/openerp-server.py index 9061b0ae3c8..9486d6e49d5 100755 --- a/bin/openerp-server.py +++ b/bin/openerp-server.py @@ -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: @@ -214,7 +214,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 diff --git a/bin/tools/misc.py b/bin/tools/misc.py index ad422411d29..5a3d21bef86 100644 --- a/bin/tools/misc.py +++ b/bin/tools/misc.py @@ -1406,5 +1406,24 @@ def upload_data(email, data, type='SURVEY'): a = upload_data_thread(email, data, type) a.start() return True + + +# port of python 2.6's attrgetter with support for dotted notation +def resolve_attr(obj, attr): + for name in attr.split("."): + obj = getattr(obj, name) + return obj + +def attrgetter(*items): + if len(items) == 1: + attr = items[0] + def g(obj): + return resolve_attr(obj, attr) + else: + def g(obj): + return tuple(resolve_attr(obj, attr) for attr in items) + return g + + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: