# HG changeset patch # User gyorgyf # Date 1363710734 0 # Node ID 89978106f0bb03f34d99a90626a94a8da1e6248e # Parent 75e67af92ef8902752636cf3ec9a7b6757930b69 commented out dir session cleanup code diff -r 75e67af92ef8 -r 89978106f0bb DirectorySession.py --- a/DirectorySession.py Tue Mar 19 13:57:27 2013 +0000 +++ b/DirectorySession.py Tue Mar 19 16:32:14 2013 +0000 @@ -25,13 +25,6 @@ instanceList = [] def __init__(self, id=None, **kwargs): - # for i in self.instanceList : - # print 'previous-sessions: ', i.id - # if (i.id == id) : - # print 'got instance already!' - # self.instanceList.append(self) - # print 'instance initialised:' + str(len(self.instanceList)) - # kwargs['SESSIONS_PATH'] = os.path.abspath(kwargs['SESSIONS_PATH']) if not id in self.cache: new_session_signal = True @@ -200,37 +193,37 @@ """Clean up expired sessions.""" now = datetime.datetime.now() log_msg = "Session x.xx: mxxx. Cherrypy::DirectorySession: Cleaning up session data at: %s Length of cache = %i " %(str(now), len(self.cache)) - print '\nCeaning up session data at %s: \n===========================' % now - print 'Length of cache = ', len(self.cache) - print 'cache members: ', self.cache.keys() + # print '\nCeaning up session data at %s: \n===========================' % now + # print 'Length of cache = ', len(self.cache) + # print 'cache members: ', self.cache.keys() cherrypy.log(log_msg) #clean up temp if server not in use - temp_path='/Users/Shared/george/sawa/sonic-annotator-webapp/static/temp/' - if len(self.cache.keys()) == 0 and os.path.exists(temp_path): - try : - for fname in os.listdir(temp_path): - os.remove(os.path.join(temp_path,fname)) - print "Note: Cleaned temp directory." - except: - print "Warning: could not clear temp directory." - pass + # temp_path='/Users/Shared/george/sawa/sonic-annotator-webapp/static/temp/' + # if len(self.cache.keys()) == 0 and os.path.exists(temp_path): + # try : + # for fname in os.listdir(temp_path): + # os.remove(os.path.join(temp_path,fname)) + # print "Note: Cleaned temp directory." + # except: + # print "Warning: could not clear temp directory." + # pass for id, (data, expiration_time) in self.cache.items(): - print 'Id: ', id - print 'expiration time: ', expiration_time - print 'Length of data: ', len(data) - print 'data members: ', data.keys() - print 'SESSIONS_PATH: ', self.SESSIONS_PATH + # print 'Id: ', id + # print 'expiration time: ', expiration_time + # print 'Length of data: ', len(data) + # print 'data members: ', data.keys() + # print 'SESSIONS_PATH: ', self.SESSIONS_PATH if expiration_time < now: - path = os.path.join(self.SESSIONS_PATH,str(id)) - if os.path.exists(path) : - for fname in os.listdir(path): - os.remove(os.path.join(path,fname)) - # os.removedirs(path) -> removes sessions too - os.rmdir(path) + # path = os.path.join(self.SESSIONS_PATH,str(id)) + # if os.path.exists(path) : + # for fname in os.listdir(path): + # os.remove(os.path.join(path,fname)) + # # os.removedirs(path) -> removes sessions too + # os.rmdir(path) try: del self.cache[id] except KeyError: