X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fsession.py;h=19bdb6b6195e805d5506060604a3fb6a4ba4be03;hb=d99a17a601c0680a325338189e6eeac0eb7d7bce;hp=3b2b2b29cc98dfbf435544ffb842e3af9b05d32c;hpb=b9e22c33901b627684450411477f6c459fc302da;p=wrw.git diff --git a/wrw/session.py b/wrw/session.py index 3b2b2b2..19bdb6b 100644 --- a/wrw/session.py +++ b/wrw/session.py @@ -157,15 +157,17 @@ class db(object): else: raise Exception("Illegal session entry: " + repr(entry[1])) - def fetch(self, req): - now = int(time.time()) - sessid = cookie.get(req, self.cookiename) - new = False + def checkclean(self): with self.lock: if self.cthread is None: self.cthread = threading.Thread(target = self.cleanloop) self.cthread.setDaemon(True) self.cthread.start() + + def fetch(self, req): + now = int(time.time()) + sessid = cookie.get(req, self.cookiename) + new = False try: if sessid is None: raise KeyError() @@ -177,13 +179,14 @@ class db(object): def ckfreeze(req): if sess.dirty(): if new: - cookie.add(req, self.cookiename, sess.id, self.path) + cookie.add(req, self.cookiename, sess.id, path=self.path) with self.lock: self.live[sess.id] = [sess.lock, sess] try: self.freeze(sess) except: pass + self.checkclean() req.oncommit(ckfreeze) return sess