Commits

dready committed 76faf52

log exception when sending build email fails in non DEBUG mode

  • Participants
  • Parent commits 32f4fac

Comments (0)

Files changed (1)

File src/factory/signals.py

 from django.db.models.signals import pre_save
 from django.core.mail import send_mail
 from django.conf import settings
+import logging
+
 
 def send_build_email(instance, **kwargs):
     if not instance.executed:
                output=instance.output,
                error=instance.error)
 
-    send_mail(subject, msg, settings.SERVER_EMAIL,
-              [instance.fabfile_recipe.notify], fail_silently=False)
+    try:
+        send_mail(subject, msg, settings.SERVER_EMAIL,
+                  [instance.fabfile_recipe.notify], fail_silently=False)
+    except:
+        if settings.DEBUG:
+            raise
+        # in production, if sending this email fails, django is unlikely to send the error mail either
+        # so we just ignore the error
+        logging.getLogger(__name__).exception("unable to send build email")