Django

Code

Changeset 4536

Show
Ignore:
Timestamp:
02/17/07 00:01:17 (2 years ago)
Author:
mtredinnick
Message:

Fixed #3067 -- Improved caching of machine hostname to increase server restart
times. Thanks SmileyChris?.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/mail.py

    r4065 r4536  
    99import random 
    1010 
    11 DNS_NAME = socket.getfqdn() # Cache the hostname 
     11# Cache the hostname, but do it lazily: socket.getfqdn() can take a couple of 
     12# seconds, which slows down the restart of the server. 
     13class CachedDnsName(object): 
     14    def __str__(self): 
     15        return self.get_fqdn() 
     16 
     17    def get_fqdn(self): 
     18        if not hasattr(self, '_fqdn'): 
     19            self._fqdn = socket.getfqdn() 
     20        return self._fqdn 
     21 
     22DNS_NAME = CachedDnsName() 
    1223 
    1324class BadHeaderError(ValueError):