[Erp5-report] r16505 - /erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Sep 20 15:38:40 CEST 2007
Author: vincent
Date: Thu Sep 20 15:38:40 2007
New Revision: 16505
URL: http://svn.erp5.org?rev=16505&view=rev
Log:
Make possible to process more than one message per dequeueMessage call. This factorises MySQL access cost which is rather high because of a sort occuring in the query. SQLQueue_readMessage will still return just one message by default, so behaviour will not change unless default number of fetched rows is increased in that ZSQLMethod.
Modified:
erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
Modified: erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/SQLQueue.py?rev=16505&r1=16504&r2=16505&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/SQLQueue.py (original)
+++ erp5/trunk/products/CMFActivity/Activity/SQLQueue.py Thu Sep 20 15:38:40 2007
@@ -85,9 +85,8 @@
now_date = DateTime()
# Next processing date in case of error
next_processing_date = now_date + float(VALIDATION_ERROR_DELAY)/86400
- result = readMessage(processing_node=processing_node, to_date=now_date)
- if len(result) > 0:
- line = result[0]
+ message_list = readMessage(processing_node=processing_node, to_date=now_date)
+ for line in message_list:
path = line.path
method_id = line.method_id
# Make sure message can not be processed anylonger
@@ -110,7 +109,7 @@
# Lower priority
activity_tool.SQLQueue_setPriority(uid=line.uid, priority=line.priority + 1)
get_transaction().commit() # Release locks before starting a potentially long calculation
- return 0
+ continue
# Try to invoke
activity_tool.invoke(m) # Try to invoke the message
@@ -135,7 +134,7 @@
LOG('SQLQueue', ERROR, 'SQLQueue.dequeueMessage raised, and cannot even set processing to zero due to an exception',
error=sys.exc_info())
raise
- return 0
+ continue
try:
if m.is_executed:
@@ -170,9 +169,8 @@
'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
+ return len(message_list) == 0
def hasActivity(self, activity_tool, object, **kw):
hasMessage = getattr(activity_tool, 'SQLQueue_hasMessage', None)
More information about the Erp5-report
mailing list