[Erp5-report] r13713 - in /erp5/trunk/products/CMFActivity/Activity: SQLDict.py SQLQueue.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Mar 27 14:37:41 CEST 2007
Author: yo
Date: Tue Mar 27 14:37:40 2007
New Revision: 13713
URL: http://svn.erp5.org?rev=13713&view=rev
Log:
Do not delay or set to an error if an exception is raised in dequeueMessage, because invoke or invokeGroup should never emit an exception, so an exception should be nothing with a message itself.
Modified:
erp5/trunk/products/CMFActivity/Activity/SQLDict.py
erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
Modified: erp5/trunk/products/CMFActivity/Activity/SQLDict.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/SQLDict.py?rev=13713&r1=13712&r2=13713&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/SQLDict.py (original)
+++ erp5/trunk/products/CMFActivity/Activity/SQLDict.py Tue Mar 27 14:37:40 2007
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
+# Copyright (c) 2002,2007 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp at nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
@@ -313,7 +313,7 @@
break
else:
get_transaction().abort()
- except Exception, exc:
+ except:
# If an exception occurs, abort the transaction to minimize the impact,
try:
get_transaction().abort()
@@ -321,33 +321,20 @@
# Unfortunately, database adapters may raise an exception against abort.
LOG('SQLDict', WARNING, 'abort failed, thus some objects may be modified accidentally')
pass
+
+ # An exception happens at somewhere else but invoke or invokeGroup, so messages
+ # themselves should not be delayed.
try:
- if isinstance(exc, ConflictError):
- # For a conflict error, simply delay the operations.
- for uid_list in uid_list_list:
- if len(uid_list):
- activity_tool.SQLDict_setPriority(uid = uid_list,
- delay = VALIDATION_ERROR_DELAY,
- retry = 1)
- else:
- # For other exceptions, put the messages to an invalid state immediately.
- for uid_list in uid_list_list:
- if len(uid_list):
- activity_tool.SQLDict_assignMessage(uid = uid_list,
- processing_node = INVOKE_ERROR_STATE)
- LOG('SQLDict', WARNING,
- 'Error in ActivityTool.invoke', error=sys.exc_info())
-
- get_transaction().commit()
+ for uid_list in uid_list_list:
+ if len(uid_list):
+ # This only sets processing to zero.
+ activity_tool.SQLDict_setPriority(uid = uid_list)
+ get_transaction().commit()
except:
LOG('SQLDict', ERROR, 'SQLDict.dequeueMessage raised, and cannot even set processing to zero due to an exception',
error=sys.exc_info())
raise
return 0
- except:
- LOG('SQLDict', ERROR, 'SQLDict.dequeueMessage raised an exception which is not a subclass of Exception',
- error=sys.exc_info())
- raise
try:
for i in xrange(len(message_list)):
Modified: erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/SQLQueue.py?rev=13713&r1=13712&r2=13713&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/SQLQueue.py (original)
+++ erp5/trunk/products/CMFActivity/Activity/SQLQueue.py Tue Mar 27 14:37:40 2007
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
+# Copyright (c) 2002,2007 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp at nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
@@ -42,7 +42,7 @@
except ImportError:
pass
-from zLOG import LOG, WARNING
+from zLOG import LOG, WARNING, ERROR
MAX_PRIORITY = 5
@@ -125,7 +125,7 @@
activity_tool.invoke(m) # Try to invoke the message
if m.is_executed: # Make sure message could be invoked
get_transaction().commit() # If successful, commit
- except Exception, exc:
+ except:
# If an exception occurs, abort the transaction to minimize the impact,
try:
get_transaction().abort()
@@ -134,48 +134,50 @@
LOG('SQLQueue', WARNING, 'abort failed, thus some objects may be modified accidentally')
pass
- if isinstance(exc, ConflictError):
- # If a conflict occurs, delay the operation.
- activity_tool.SQLQueue_setPriority(uid = line.uid, date = next_processing_date,
+ # An exception happens at somewhere else but invoke, so messages
+ # themselves should not be delayed.
+ try:
+ activity_tool.SQLQueue_setPriority(uid = line.uid, date = line.date,
priority = line.priority)
+ get_transaction().commit()
+ except:
+ LOG('SQLQueue', ERROR, 'SQLQueue.dequeueMessage raised, and cannot even set processing to zero due to an exception',
+ error=sys.exc_info())
+ raise
+ return 0
+
+ try:
+ if m.is_executed:
+ activity_tool.SQLQueue_delMessage(uid=[line.uid]) # Delete it
else:
- # For the other exceptions, put it into an error state.
- activity_tool.SQLQueue_assignMessage(uid = line.uid,
- processing_node = INVOKE_ERROR_STATE)
- LOG('SQLQueue', WARNING,
- 'Error in ActivityTool.invoke', error=sys.exc_info())
-
+ try:
+ # If not, abort transaction and start a new one
+ get_transaction().abort()
+ except:
+ # Unfortunately, database adapters may raise an exception against abort.
+ LOG('SQLQueue', WARNING, 'abort failed, thus some objects may be modified accidentally')
+ pass
+
+ if type(m.exc_type) is ClassType \
+ and issubclass(m.exc_type, ConflictError):
+ activity_tool.SQLQueue_setPriority(uid = line.uid,
+ date = next_processing_date,
+ priority = line.priority)
+ elif line.priority > MAX_PRIORITY:
+ # This is an error
+ activity_tool.SQLQueue_assignMessage(uid = line.uid,
+ processing_node = INVOKE_ERROR_STATE)
+ # Assign message back to 'error' state
+ m.notifyUser(activity_tool) # Notify Error
+ else:
+ # Lower priority
+ activity_tool.SQLQueue_setPriority(uid=line.uid, date = next_processing_date,
+ priority = line.priority + 1)
get_transaction().commit()
- return 0
-
-
- if m.is_executed:
- activity_tool.SQLQueue_delMessage(uid=[line.uid]) # Delete it
- else:
- try:
- # If not, abort transaction and start a new one
- get_transaction().abort()
- except:
- # Unfortunately, database adapters may raise an exception against abort.
- LOG('SQLQueue', WARNING, 'abort failed, thus some objects may be modified accidentally')
- pass
-
- if type(m.exc_type) is ClassType \
- and issubclass(m.exc_type, ConflictError):
- activity_tool.SQLQueue_setPriority(uid = line.uid,
- date = next_processing_date,
- priority = line.priority)
- elif line.priority > MAX_PRIORITY:
- # This is an error
- activity_tool.SQLQueue_assignMessage(uid = line.uid,
- processing_node = INVOKE_ERROR_STATE)
- # Assign message back to 'error' state
- m.notifyUser(activity_tool) # Notify Error
- else:
- # Lower priority
- activity_tool.SQLQueue_setPriority(uid=line.uid, date = next_processing_date,
- priority = line.priority + 1)
- get_transaction().commit()
+ except:
+ LOG('SQLQueue', ERROR, 'SQLQueue.dequeueMessage raised an exception during checking for the results of processed messages',
+ error=sys.exc_info())
+ raise
return 0
get_transaction().commit() # Release locks before starting a potentially long calculation
return 1
More information about the Erp5-report
mailing list