Dolda2000 GitWeb
/
wrw.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added a simple filesystem handler.
[wrw.git]
/
wrw
/
session.py
diff --git
a/wrw/session.py
b/wrw/session.py
index
513725d
..
9e91ad9
100644
(file)
--- a/
wrw/session.py
+++ b/
wrw/session.py
@@
-76,7
+76,6
@@
class db(object):
self.cookiename = cookiename
self.path = path
self.lock = threading.Lock()
self.cookiename = cookiename
self.path = path
self.lock = threading.Lock()
- self.lastuse = 0
self.cthread = None
self.freezetime = 3600
self.cthread = None
self.freezetime = 3600
@@
-99,18
+98,17
@@
class db(object):
def cleanloop(self):
try:
def cleanloop(self):
try:
- lastuse = self.lastuse
- while self.lastuse >= lastuse:
- lastuse = self.lastuse
+ while True:
time.sleep(300)
self.clean()
time.sleep(300)
self.clean()
+ if len(self.live) == 0:
+ break
finally:
with self.lock:
self.cthread = None
def fetch(self, req):
now = int(time.time())
finally:
with self.lock:
self.cthread = None
def fetch(self, req):
now = int(time.time())
- self.lastuse = now
sessid = cookie.get(req, self.cookiename)
with self.lock:
if self.cthread is None:
sessid = cookie.get(req, self.cookiename)
with self.lock:
if self.cthread is None:
@@
-131,18
+129,17
@@
class db(object):
except KeyError:
sess = session()
self.live[sess.id] = sess
except KeyError:
sess = session()
self.live[sess.id] = sess
- req.oncommit(self.addcookie)
+ sess.new = True
req.oncommit(self.ckfreeze)
return sess
req.oncommit(self.ckfreeze)
return sess
- def addcookie(self, req):
- sess = req.item(self.fetch)
- cookie.add(req, self.cookiename, sess.id, self.path)
-
def ckfreeze(self, req):
sess = req.item(self.fetch)
if sess.dirty():
try:
def ckfreeze(self, req):
sess = req.item(self.fetch)
if sess.dirty():
try:
+ if getattr(sess, "new", False):
+ cookie.add(req, self.cookiename, sess.id, self.path)
+ del sess.new
self.freeze(sess)
except:
pass
self.freeze(sess)
except:
pass