@@ -20,8 +20,9 @@
|
||||
##############################################################################
|
||||
|
||||
from osv import osv,fields
|
||||
from operator import attrgetter
|
||||
from tools.misc import attrgetter
|
||||
import time
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Properties
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<assert
|
||||
model="res.currency.rate"
|
||||
search="[('currency_id', '=', ref('INR'))]"
|
||||
count="3"
|
||||
count="1"
|
||||
string="Rate entries for Indian rupee">
|
||||
<test expr="True"/>
|
||||
</assert>
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
<!-- model="res.currency"-->
|
||||
<!-- id="INR"-->
|
||||
<!-- string="Indian rupee rate in 2009">-->
|
||||
<!-- <!-- date specified in data element's context -->-->
|
||||
<!-- date specified in data element's context -->
|
||||
<!-- <test expr="str(rate)">65.8287</test>-->
|
||||
<!-- </assert>-->
|
||||
<!-- </assert> -->
|
||||
<assert
|
||||
model="res.currency"
|
||||
id="INR"
|
||||
string="Indian rupee rate in 2002"
|
||||
context="{'date': '2010-06-01'}">
|
||||
<test expr="str(rate)">58.8287</test>
|
||||
<test expr="str(rate)">59.9739</test>
|
||||
</assert>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
+2
-2
@@ -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()
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user