Merge branch 'master' into python3
authorFredrik Tolf <fredrik@dolda2000.com>
Fri, 29 Jun 2012 01:47:06 +0000 (03:47 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Fri, 29 Jun 2012 01:47:06 +0000 (03:47 +0200)
Conflicts:
wrw/session.py

1  2 
wrw/session.py

diff --cc 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: