瀏覽代碼

Make error e-mail timeout configurable by adding the EMAIL_TIMEOUT setting. Closes #248.

Ask Solem 15 年之前
父節點
當前提交
9e26050c70
共有 2 個文件被更改,包括 4 次插入2 次删除
  1. 1 0
      celery/conf.py
  2. 3 2
      celery/utils/mail.py

+ 1 - 0
celery/conf.py

@@ -97,6 +97,7 @@ _DEFAULTS = {
     "SERVER_EMAIL": "celery@localhost",
     "EMAIL_HOST": "localhost",
     "EMAIL_PORT": 25,
+    "EMAIL_TIMEOUT": 2,
     "ADMINS": (),
 }
 

+ 3 - 2
celery/utils/mail.py

@@ -38,7 +38,7 @@ class Message(object):
 class Mailer(object):
 
     def __init__(self, host="localhost", port=0, user=None, password=None,
-            timeout=2):
+            timeout=None):
         self.host = host
         self.port = port
         self.user = user
@@ -81,7 +81,8 @@ def mail_admins(subject, message, fail_silently=False):
     try:
         mailer = Mailer(conf.EMAIL_HOST, conf.EMAIL_PORT,
                         conf.EMAIL_HOST_USER,
-                        conf.EMAIL_HOST_PASSWORD)
+                        conf.EMAIL_HOST_PASSWORD,
+                        conf.EMAIL_TIMEOUT)
         mailer.send(message)
     except Exception, exc:
         if not fail_silently: