Ticket #3067: better_servername_caching.patch

File better_servername_caching.patch, 753 bytes (added by Chris Beaven, 18 years ago)
  • django/core/mail.py

     
    88import time
    99import random
    1010
    11 DNS_NAME = socket.getfqdn() # Cache the hostname
     11# Cache the hostname, but do it "lazily". `getfqdn` can take a couple of
     12# seconds, which slows down the restart of the server (especially noticable
     13# on the development server).
     14class CacheDnsName(object):
     15    def __repr__(self):
     16        return self.get_fqdn()
     17    def get_fqdn(self):
     18        if not hasattr(self, '_fqdn'):
     19            self._fqdn = socket.getfqdn()
     20        return self._fqdn
     21DNS_NAME = CacheDnsName()
    1222
    1323class BadHeaderError(ValueError):
    1424    pass
Back to Top