From: kedder Date: Mon, 13 Jan 2003 22:14:00 +0000 (+0000) Subject: cleaning old unused sessions only once per hour, not on every cgi request X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d8a0146f936e9db807bbe2b30bfd21dd156a0c3b;p=roundup.git cleaning old unused sessions only once per hour, not on every cgi request git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1448 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/CHANGES.txt b/CHANGES.txt index 9ed580d..470a683 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,7 +1,7 @@ This file contains the changes to the Roundup system over time. The entries are given with the most recent entry first. -2003-??-?? 0.6.0 (?) +2003-??-?? 0.6.0 - better hyperlinking in web message texts - support setting of properties on message and file through web and email interface (thanks John Rouillard) @@ -9,7 +9,9 @@ are given with the most recent entry first. cc addresses, different from address and different nosy list property) (thanks John Rouillard) - applied patch for nicer history display (sf feature 638280) - +- cleaning old unused sessions only once per hour, not on every cgi + request. It is greatly improves web interface performance, especially + on trackers under high load 2003-??-?? 0.5.5 - fixed rdbms searching by ID (sf bug 666615) @@ -28,7 +30,7 @@ are given with the most recent entry first. (multipart/alternative, "fw" and content-type "name") - fire auditors and reactors in rdbms retire (thanks Sheila King) - better match for mailgw help "command" text -- handle :add: better in cgi form parsing (sf bug 663235) +- handle :add: better in cgi form parsing (sf bug 6632.35) - handle all-whitespace multilink values in forms (sf bug 663855) - fixed searching on date / interval fields (sf bug 658157) - fixed form elements names in search form to allow grouping and sorting diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py index 170d86b..b2ee207 100644 --- a/roundup/cgi/client.py +++ b/roundup/cgi/client.py @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.66 2003-01-11 23:52:28 richard Exp $ +# $Id: client.py,v 1.67 2003-01-13 22:14:00 kedder Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -190,24 +190,34 @@ class Client: # everything else self.write(cgitb.html()) + def clean_sessions(self): + '''age sessions, remove when they haven't been used for a week. + Do it only once an hour''' + sessions = self.db.sessions + last_clean = sessions.get('last_clean', 'last_use') or 0 + + week = 60*60*24*7 + hour = 60*60 + now = time.time() + if now - last_clean > hour: + # remove age sessions + for sessid in sessions.list(): + print sessid + interval = now - sessions.get(sessid, 'last_use') + if interval > week: + sessions.destroy(sessid) + sessions.set('last_clean', last_use=time.time()) + def determine_user(self): ''' Determine who the user is ''' # determine the uid to use self.opendb('admin') - + # clean age sessions + self.clean_sessions() # make sure we have the session Class sessions = self.db.sessions - # age sessions, remove when they haven't been used for a week - # TODO: this shouldn't be done every access - week = 60*60*24*7 - now = time.time() - for sessid in sessions.list(): - interval = now - sessions.get(sessid, 'last_use') - if interval > week: - sessions.destroy(sessid) - # look up the user session cookie cookie = Cookie.Cookie(self.env.get('HTTP_COOKIE', '')) user = 'anonymous'