Kaydet (Commit) f5ede9c5 authored tarafından Malcolm Tredinnick's avatar Malcolm Tredinnick

Fixed #3067 -- Improved caching of machine hostname to increase server restart

times. Thanks SmileyChris.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@4536 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst ed3d787e
......@@ -8,7 +8,18 @@ import socket
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment