From 629a8f3927ca67b9f35c0d1a48d2b042d728bf3b Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Tue, 5 Feb 2008 22:22:25 +0000
Subject: [PATCH] Prevent exceptions raised in notifyUser from making
 finalizeMessageExecution raise.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19089 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/CMFActivity/Activity/SQLDict.py  | 18 +++++++++++-------
 product/CMFActivity/Activity/SQLQueue.py | 19 +++++++++++--------
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/product/CMFActivity/Activity/SQLDict.py b/product/CMFActivity/Activity/SQLDict.py
index 8d31df784e..c595c239b8 100644
--- a/product/CMFActivity/Activity/SQLDict.py
+++ b/product/CMFActivity/Activity/SQLDict.py
@@ -373,13 +373,17 @@ class SQLDict(RAMDict, SQLBase):
         LOG('SQLDict', PANIC, 'Failed to unreserve %r' % (make_available_uid_list, ), error=sys.exc_info())
       else:
         LOG('SQLDict', TRACE, 'Freed messages %r' % (make_available_uid_list, ))
-    for m in notify_user_list:
-      m.notifyUser(activity_tool)
-    for m in message_with_active_process_list:
-      active_process = activity_tool.unrestrictedTraverse(m.active_process)
-      if not active_process.hasActivity():
-        # No more activity
-        m.notifyUser(activity_tool, message="Process Finished") # XXX commit bas ???
+    try:
+      for m in notify_user_list:
+        m.notifyUser(activity_tool)
+      for m in message_with_active_process_list:
+        active_process = activity_tool.unrestrictedTraverse(m.active_process)
+        if not active_process.hasActivity():
+          # No more activity
+          m.notifyUser(activity_tool, message="Process Finished") # XXX commit bas ???
+    except:
+      # Notification failures must not cause this method to raise.
+      LOG('SQLDict', WARNING, 'Exception during notification phase of finalizeMessageExecution', error=sys.exc_info())
 
   # Queue semantic
   def dequeueMessage(self, activity_tool, processing_node):
diff --git a/product/CMFActivity/Activity/SQLQueue.py b/product/CMFActivity/Activity/SQLQueue.py
index 750455d683..60c20dd958 100644
--- a/product/CMFActivity/Activity/SQLQueue.py
+++ b/product/CMFActivity/Activity/SQLQueue.py
@@ -244,14 +244,17 @@ class SQLQueue(RAMQueue, SQLBase):
                                              processing_node=INVOKE_ERROR_STATE)
       except:
         LOG('SQLQueue', PANIC, 'Failed to set message to error state for %r' % (final_error_uid_list, ), error=sys.exc_info())
-    for m in notify_user_list:
-      m.notifyUser(activity_tool)
-    for m in message_with_active_process_list:
-      active_process = activity_tool.unrestrictedTraverse(m.active_process)
-      if not active_process.hasActivity():
-        # No more activity
-        m.notifyUser(activity_tool, message="Process Finished") # XXX commit bas ???
-
+    try:
+      for m in notify_user_list:
+        m.notifyUser(activity_tool)
+      for m in message_with_active_process_list:
+        active_process = activity_tool.unrestrictedTraverse(m.active_process)
+        if not active_process.hasActivity():
+          # No more activity
+          m.notifyUser(activity_tool, message="Process Finished") # XXX commit bas ???
+    except:
+      # Notification failures must not cause this method to raise.
+      LOG('SQLQueue', WARNING, 'Exception during notification phase of finalizeMessageExecution', error=sys.exc_info())
 
   def dequeueMessage(self, activity_tool, processing_node):
     def makeMessageListAvailable(uid_list):
-- 
2.30.9