Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #3067 -- Improved caching of machine hostname to increase serve…

…r restart

times. Thanks SmileyChris.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent ed3d787 commit f5ede9c5c8bb2ebef362b374330c6d1200e6706b @malcolmt malcolmt committed
Showing with 12 additions and 1 deletion.
  1. +12 −1 django/core/
13 django/core/
@@ -8,7 +8,18 @@
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):

0 comments on commit f5ede9c

Please sign in to comment.
Something went wrong with that request. Please try again.