Author: mtredinnick
Date: 2007-02-17 00:01:17 -0600 (Sat, 17 Feb 2007)
New Revision: 4536

Modified:
   django/trunk/django/core/mail.py
Log:
Fixed #3067 -- Improved caching of machine hostname to increase server restart
times. Thanks SmileyChris.


Modified: django/trunk/django/core/mail.py
===================================================================
--- django/trunk/django/core/mail.py    2007-02-17 05:51:45 UTC (rev 4535)
+++ django/trunk/django/core/mail.py    2007-02-17 06:01:17 UTC (rev 4536)
@@ -8,8 +8,19 @@
 import time
 import random
 
-DNS_NAME = socket.getfqdn() # Cache the hostname
+# Cache the hostname, but do it lazily: socket.getfqdn() can take a couple of
+# seconds, which slows down the restart of the server.
+class CachedDnsName(object):
+    def __str__(self):
+        return self.get_fqdn()
 
+    def get_fqdn(self):
+        if not hasattr(self, '_fqdn'):
+            self._fqdn = socket.getfqdn()
+        return self._fqdn
+
+DNS_NAME = CachedDnsName()
+
 class BadHeaderError(ValueError):
     pass
 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to