'Clean up expired sessions.'

def clean_up(self):

    now = self.now()
    for (id, (data, expiration_time)) in copyitems(self.cache):
        if (expiration_time <= now):
            try:
                del self.cache[id]
            except KeyError:
                pass
            try:
                del self.locks[id]
            except KeyError:
                pass
    for id in list(self.locks):
        if (id not in self.cache):
            self.locks.pop(id, None)
