Pārlūkot izejas kodu

try/catch in case of notification error

root 10 gadus atpakaļ
vecāks
revīzija
e0c4091fcb
1 mainītis faili ar 13 papildinājumiem un 9 dzēšanām
  1. 13 9
      tracim/tracim/lib/notifications.py

+ 13 - 9
tracim/tracim/lib/notifications.py Parādīt failu

53
         # INFO - D.A. - 2014-11-05 - Emails are sent through asynchronous jobs. For that reason, we do not
53
         # INFO - D.A. - 2014-11-05 - Emails are sent through asynchronous jobs. For that reason, we do not
54
         # give SQLAlchemy objects but ids only (SQLA objects are related to a given thread/session)
54
         # give SQLAlchemy objects but ids only (SQLA objects are related to a given thread/session)
55
         #
55
         #
56
-        if global_config.EMAIL_NOTIFICATION_PROCESSING_MODE.lower()==global_config.CST.ASYNC.lower():
57
-            logger.info(self, 'Sending email in ASYNC mode')
58
-            # TODO - D.A - 2014-11-06
59
-            # This feature must be implemented in order to be able to scale to large communities
60
-            raise NotImplementedError('Sending emails through ASYNC mode is not working yet')
61
-            asyncjob_perform(EmailNotifier(self._smtp_config, global_config).notify_content_update, self._user.user_id, content.content_id)
62
-        else:
63
-            logger.info(self, 'Sending email in SYNC mode')
64
-            EmailNotifier(self._smtp_config, global_config).notify_content_update(self._user.user_id, content.content_id)
56
+        try:
57
+            if global_config.EMAIL_NOTIFICATION_PROCESSING_MODE.lower()==global_config.CST.ASYNC.lower():
58
+                logger.info(self, 'Sending email in ASYNC mode')
59
+                # TODO - D.A - 2014-11-06
60
+                # This feature must be implemented in order to be able to scale to large communities
61
+                raise NotImplementedError('Sending emails through ASYNC mode is not working yet')
62
+                asyncjob_perform(EmailNotifier(self._smtp_config, global_config).notify_content_update, self._user.user_id, content.content_id)
63
+            else:
64
+                logger.info(self, 'Sending email in SYNC mode')
65
+                EmailNotifier(self._smtp_config, global_config).notify_content_update(self._user.user_id, content.content_id)
66
+        except Exception as e:
67
+            logger.error(self, 'Exception catched during email notification: {}'.format(e.__str__()))
65
 
68
 
66
 class EST(object):
69
 class EST(object):
67
     """
70
     """
119
             logger.info(self, 'Skipping notification as nobody subscribed to in workspace {}'.format(content.workspace.label))
122
             logger.info(self, 'Skipping notification as nobody subscribed to in workspace {}'.format(content.workspace.label))
120
             return
123
             return
121
 
124
 
125
+
122
         logger.info(self, 'Sending asynchronous emails to {} user(s)'.format(len(notifiable_roles)))
126
         logger.info(self, 'Sending asynchronous emails to {} user(s)'.format(len(notifiable_roles)))
123
         # INFO - D.A. - 2014-11-06
127
         # INFO - D.A. - 2014-11-06
124
         # The following email sender will send emails in the async task queue
128
         # The following email sender will send emails in the async task queue