From: Fredrik Tolf Date: Fri, 29 Jun 2012 01:47:06 +0000 (+0200) Subject: Merge branch 'master' into python3 X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=ab92e396057cd617b1607f437d860ff89f5780a2;p=wrw.git Merge branch 'master' into python3 Conflicts: wrw/session.py --- ab92e396057cd617b1607f437d860ff89f5780a2 diff --cc wrw/session.py index 02d1983,edf8f7d..90d460b --- a/wrw/session.py +++ b/wrw/session.py @@@ -83,19 -86,34 +86,34 @@@ class db(object) def clean(self): now = int(time.time()) with self.lock: - dlist = [] - for sess in self.live.values(): - if sess.atime + self.freezetime < now: - try: - if sess.dirty(): - self.freeze(sess) - except: - if sess.atime + sess.expire < now: - dlist.append(sess) - else: - dlist.append(sess) - for sess in dlist: - del self.live[sess.id] - clist = self.live.keys() ++ clist = list(self.live.keys()) + for sessid in clist: + with self.lock: + try: + entry = self.live[sessid] + except KeyError: + continue + with entry[0]: + rm = False + if entry[1] == "retired": + pass + elif entry[1] is None: + pass + else: + sess = entry[1] + if sess.atime + self.freezetime < now: + try: + if sess.dirty(): + self.freeze(sess) + except: + if sess.atime + sess.expire < now: + rm = True + else: + rm = True + if rm: + entry[1] = "retired" + with self.lock: + del self.live[sessid] def cleanloop(self): try: