From 0b591734431eaeb628efa7151741e4823abd4734 Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Mon, 26 Jan 2004 20:20:27 +0000 Subject: [PATCH] Make sure repeated calls to invoke are compatible with invalidated object git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@345 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/CMFActivity/Activity/SQLDict.py | 26 +++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/product/CMFActivity/Activity/SQLDict.py b/product/CMFActivity/Activity/SQLDict.py index 2708e1b22b..f648a95423 100755 --- a/product/CMFActivity/Activity/SQLDict.py +++ b/product/CMFActivity/Activity/SQLDict.py @@ -73,15 +73,20 @@ class SQLDict(RAMDict): activity_tool.SQLDict_processMessage(path=path, method_id=method_id, processing_node = processing_node) get_transaction().commit() # Release locks before starting a potentially long calculation m = self.loadMessage(line.message) - if m.validate(self, activity_tool): # We should validate each time XXX in case someone is deleting it at the same time - retry = 0 - while retry < MAX_RETRY: + retry = 0 + while retry < MAX_RETRY: + if m.validate(self, activity_tool): # We should validate each time XXX in case someone is deleting it at the same time + valid = 1 activity_tool.invoke(m) # Try to invoke the message if m.is_executed: retry=MAX_RETRY else: get_transaction().abort() # Abort and retry retry = retry + 1 + else: + valid = 0 + retry=MAX_RETRY + if valid: # We should validate each time XXX in case someone is deleting it at the same time if m.is_executed: # Make sure message could be invoked activity_tool.SQLDict_delMessage(path=path, method_id=method_id, processing_node=processing_node) # Delete it get_transaction().commit() # If successful, commit @@ -128,7 +133,20 @@ class SQLDict(RAMDict): # Only invoke once (it would be different for a queue) method_dict[method_id] = 1 m = self.loadMessage(line.message) - if m.validate(self, activity_tool): + retry = 0 + while retry < MAX_RETRY: + if m.validate(self, activity_tool): # We should validate each time XXX in case someone is deleting it at the same time + valid = 1 + activity_tool.invoke(m) # Try to invoke the message + if m.is_executed: + retry=MAX_RETRY + else: + get_transaction().abort() # Abort and retry + retry = retry + 1 + else: + valid = 0 + retry=MAX_RETRY + if valid: # We should validate each time XXX in case someone is deleting it at the same time retry = 0 while retry < MAX_RETRY: activity_tool.invoke(m) # Try to invoke the message -- 2.30.9