Issue #1174 new

Lock timeout

Anonymous created an issue

I don't know if it is really an issue or not. I have a request that takes over 5 minutes to get the response. I've fixed the timeout reponse settings, but despite of this I get a key error exception. This is the function throwing the exception:

session.py: class class RamSession(Session): # ... def release_lock(self): """Release the lock on the currently-loaded session data.""" self.locks[self.id].release() self.locked = False

the exception is thrown because self.id is no more in the locks dictionary; in fact, it has been removed by the method clean_up as an obsolete object, and this because the lock has never been put in cache!

Now, to solve the problem, I'm going to correct my session.py in this way:

class class RamSession(Session): # ... def acquire_lock(self): """Acquire an exclusive lock on the currently-loaded session data.""" self.locked = True self.locks.setdefault(self.id, threading.RLock()).acquire() if not self.id in self.cache: t = datetime.timedelta(seconds = self.timeout * 60) expiration_time = self.now() + t self._save(expiration_time)

def release_lock(self):
    """Release the lock on the currently-loaded session data."""
    if self.id in self.locks:
        if self.id in self.cache: self._delete()
        self.locks[self.id].release()
    self.locked = False

Please, feel free to insult me if I'm missing something!!

Comments (0)

  1. Log in to comment