Commit 03a84340 authored by Hardik Juneja's avatar Hardik Juneja

CMFActivity: Make ValidationErrorDelay overridable and change getResult to getResultDict

parent 670ea4e6
...@@ -146,21 +146,23 @@ class ActiveProcess(Base): ...@@ -146,21 +146,23 @@ class ActiveProcess(Base):
except AttributeError: except AttributeError:
# BBB: self was created before implementation of __init__ # BBB: self was created before implementation of __init__
return [] return []
if type(result_list) is not ConflictFreeLog: # BBB: result_list is IOBTree if type(result_list) is not ConflictFreeLog:
# BBB: result_list is IOBTree or LOBTree
return result_list.values() return result_list.values()
return list(result_list) return list(result_list)
security.declareProtected(CMFCorePermissions.ManagePortal, 'getResultDict') security.declareProtected(CMFCorePermissions.ManagePortal, 'getResultDict')
def getResultDict(self, **kw): def getResultDict(self, **kw):
""" """
Returns the result with requested key else None Returns the result Dict
""" """
try: try:
result_list = self.result_list result_dict = self.result_dict
result = result_list[key] if type(result_dict) is not ConflictFreeLog:
except KeyError: return result_dict
return None return {}
return result except AttributeError:
return {}
security.declareProtected(CMFCorePermissions.ManagePortal, 'activateResult') security.declareProtected(CMFCorePermissions.ManagePortal, 'activateResult')
def activateResult(self, result): def activateResult(self, result):
......
...@@ -43,7 +43,7 @@ INVALID_ORDER = 2 ...@@ -43,7 +43,7 @@ INVALID_ORDER = 2
# Time global parameters # Time global parameters
MAX_PROCESSING_TIME = 900 # in seconds MAX_PROCESSING_TIME = 900 # in seconds
VALIDATION_ERROR_DELAY = 1 # in seconds VALIDATION_ERROR_DELAY = 15 # in seconds
class Queue(object): class Queue(object):
""" """
......
...@@ -571,6 +571,7 @@ class SQLBase(Queue): ...@@ -571,6 +571,7 @@ class SQLBase(Queue):
make_available_uid_list = [] make_available_uid_list = []
notify_user_list = [] notify_user_list = []
executed_uid_list = deletable_uid_list executed_uid_list = deletable_uid_list
if uid_to_duplicate_uid_list_dict is not None: if uid_to_duplicate_uid_list_dict is not None:
for m in message_list: for m in message_list:
if m.getExecutionState() == MESSAGE_NOT_EXECUTED: if m.getExecutionState() == MESSAGE_NOT_EXECUTED:
......
...@@ -31,7 +31,6 @@ from functools import total_ordering ...@@ -31,7 +31,6 @@ from functools import total_ordering
from zLOG import LOG, TRACE, INFO, WARNING, ERROR, PANIC from zLOG import LOG, TRACE, INFO, WARNING, ERROR, PANIC
from SQLBase import SQLBase, sort_message_key from SQLBase import SQLBase, sort_message_key
from Products.CMFActivity.ActivityTool import Message from Products.CMFActivity.ActivityTool import Message
from Queue import Queue, VALIDATION_ERROR_DELAY, VALID, INVALID_PATH
# Stop validating more messages when this limit is reached # Stop validating more messages when this limit is reached
MAX_VALIDATED_LIMIT = 1000 MAX_VALIDATED_LIMIT = 1000
......
...@@ -63,9 +63,10 @@ if ENABLE_JOBLIB: ...@@ -63,9 +63,10 @@ if ENABLE_JOBLIB:
self.callback = callback self.callback = callback
def get(self, timeout=None): def get(self, timeout=None):
if self.active_process.getResult(self.active_process_sig) is None: resultDict = self.active_process.getResultDict()
if not resultDict.has_key(self.active_process_sig):
raise ConflictError raise ConflictError
result = self.active_process.getResult(self.active_process_sig).result result = resultDict[self.active_process_sig].result
if isinstance(result, Exception): if isinstance(result, Exception):
raise result raise result
...@@ -96,7 +97,8 @@ if ENABLE_JOBLIB: ...@@ -96,7 +97,8 @@ if ENABLE_JOBLIB:
# create a signature and convert it to integer # create a signature and convert it to integer
sig = joblib_hash(batch.items[0]) sig = joblib_hash(batch.items[0])
sigint = int(sig, 16) % (10 ** 16) sigint = int(sig, 16) % (10 ** 16)
if not self.active_process.getResult(sigint): resultDict = self.active_process.getResultDict()
if not resultDict.has_key(sigint):
joblib_result = portal_activities.activate(activity='SQLJoblib', joblib_result = portal_activities.activate(activity='SQLJoblib',
tag="joblib_%s" % active_process_id, tag="joblib_%s" % active_process_id,
signature=sig, signature=sig,
......
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