[FIX] mail: avoid catching (transient) MemoryErrors when sending outgoing mail
authorOlivier Dony <odo@openerp.com>
Wed, 30 Apr 2014 10:25:52 +0000 (12:25 +0200)
committerOlivier Dony <odo@openerp.com>
Wed, 30 Apr 2014 10:25:52 +0000 (12:25 +0200)
This would permanently mark the mail as failed while
there is a good chance it will be sent properly next
time it is retried (provided the memory situation
improves or the server/worker has restarted).

bzr revid: odo@openerp.com-20140430102552-qkwv20b20nve64th

addons/mail/mail_mail.py

index d49c84b..b558f47 100644 (file)
@@ -319,6 +319,10 @@ class mail_mail(osv.Model):
                 # see revid:odo@openerp.com-20120622152536-42b2s28lvdv3odyr in 6.1
                 if mail_sent:
                     self._postprocess_sent_message(cr, uid, mail, context=context)
+            except MemoryError:
+                # prevent catching transient MemoryErrors, bubble up to notify user or abort cron job
+                # instead of marking the mail as failed
+                raise
             except Exception:
                 _logger.exception('failed sending mail.mail %s', mail.id)
                 mail.write({'state': 'exception'})