Django

Code

Changeset 8620

Show
Ignore:
Timestamp:
08/27/08 03:58:51 (3 months ago)
Author:
mtredinnick
Message:

Fixed #8311 -- Avoid an infinite loop with session key generation when using
the cache backend and memcached goes away (or is not running).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/sessions/backends/cache.py

    r8410 r8620  
    1818 
    1919    def create(self): 
    20         while True: 
     20        # Because a cache can fail silently (e.g. memcache), we don't know if 
     21        # we are failing to create a new session because of a key collision or 
     22        # because the cache is missing. So we try for a (large) number of times 
     23        # and then raise an exception. That's the risk you shoulder if using 
     24        # cache backing. 
     25        for i in xrange(10000): 
    2126            self.session_key = self._get_new_session_key() 
    2227            try: 
     
    2631            self.modified = True 
    2732            return 
     33        raise RuntimeError("Unable to create a new session key.") 
    2834 
    2935    def save(self, must_create=False):