Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 979

Show
Ignore:
Timestamp:
02/21/06 01:09:46
Author:
rdelon
Message:

Clean-up sessions in different thread (to avoid blocking the request)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/filters/sessionfilter.py

    r978 r979  
    3333import sha 
    3434import time 
     35import thread 
    3536import threading 
    3637import types 
     
    113114        if cherrypy._session_last_clean_up_time + clean_up_delay < now: 
    114115            cherrypy._session_last_clean_up_time = now 
    115             sess.session_storage.clean_up() 
     116            # Run clean_up function in other thread to avoid blocking 
     117            #   this request 
     118            thread.start_new_thread(sess.session_storage.clean_up, (sess,)) 
    116119         
    117120        # Check if request came with a session ID 
     
    231234        sess.locked = False 
    232235     
    233     def clean_up(self): 
    234         sess = cherrypy.request._session 
     236    def clean_up(self, sess): 
    235237        to_be_deleted = [] 
    236238        now = datetime.datetime.now() 
     
    285287        sess.locked = False 
    286288     
    287     def clean_up(self): 
    288         sess = cherrypy.request._session 
     289    def clean_up(self, sess): 
    289290        storagePath = cherrypy.config.get('session_filter.storage_path') 
    290291        now = datetime.datetime.now() 
     
    391392        self.cursor = None 
    392393     
    393     def clean_up(self): 
    394         sess = cherrypy.request._session 
     394    def clean_up(self, sess): 
    395395        now = datetime.datetime.now() 
    396396        self.cursor.execute( 

Hosted by WebFaction

Log in as guest/cpguest to create tickets