Commit ec6d5c43 authored by Julien Muchembled's avatar Julien Muchembled

Also allow to specify retry parameters in activate_kw

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32882 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7122fe43
......@@ -15,12 +15,16 @@ def _getActivityRuntimeEnvironment():
class BaseMessage:
delay = None
def __property(**kw):
(k, v), = kw.items()
return property(lambda self: self.activity_kw.get(k, v))
delay = __property(delay=None)
# None means infinite retry
max_retry = 5
max_retry = __property(max_retry=5)
# For errors happening after message invocation (ConflictError),
# should we retry quickly without increasing 'retry' count ?
conflict_retry = True
conflict_retry = __property(conflict_retry=True)
class ActivityRuntimeEnvironment(object):
......@@ -32,4 +36,4 @@ class ActivityRuntimeEnvironment(object):
# There is no point allowing to modify other attributes from a message
for k in kw:
getattr(BaseMessage, k)
self._message.__dict__.update(kw)
self._message.activity_kw.update(kw)
......@@ -1659,12 +1659,12 @@ class TestCMFActivity(ERP5TypeTestCase):
self.getActivityRuntimeEnvironment().edit(**edit_kw)
if conflict is not None:
raise conflict and ConflictError or Exception
def check(retry_list):
def check(retry_list, **activate_kw):
fail = retry_list[-1][0] is not None and 1 or 0
for activity in 'SQLDict', 'SQLQueue':
exec_count[0] = 0
activity_tool.activate(activity=activity, priority=priority(1,6)) \
.doSomething(retry_list)
activity_tool.activate(activity=activity, priority=priority(1,6),
**activate_kw).doSomething(retry_list)
get_transaction().commit()
self.flushAllActivities(silent=1)
self.assertEqual(len(retry_list), exec_count[0])
......@@ -1687,6 +1687,7 @@ class TestCMFActivity(ERP5TypeTestCase):
# ... even in case of ConflictError
check([(True, {'max_retry': 0}),
(True, {'max_retry': 0, 'conflict_retry': 0})])
check([(True, None)] * 6, conflict_retry=False)
# Customized number of retries
for n in 3, 9:
check([(False, {'max_retry': n})] * n + [(None, None)])
......@@ -1696,6 +1697,7 @@ class TestCMFActivity(ERP5TypeTestCase):
check([(False, {'max_retry': None})] * n + [(None, None)])
check([(False, {'max_retry': None})] * n + [(False, {'max_retry': 0})])
check([(False, {'max_retry': None})] * 9 + [(False, None)])
finally:
del activity_tool.__class__.doSomething
self.assertFalse(activity_tool.getMessageList())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment