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

Changeset 442

Show
Ignore:
Timestamp:
07/09/05 21:26:14
Author:
mikerobi
Message:

thread safety dest for the sessionFilter

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/test/test_session_filter.py

    r431 r442  
    3434from cherrypy.test import helper 
    3535 
     36localDir = os.path.dirname(__file__) 
     37curpath = os.path.normpath(os.path.join(os.getcwd(), localDir)) 
     38tmpFolder = os.path.join(curpath, 'tmpSessionTestData') 
     39 
    3640server_conf = { 
    3741               'global' :  
     
    3943                    'server.socketHost': helper.HOST, 
    4044                    'server.socketPort': helper.PORT, 
    41                     'server.threadPool': 10
     45                    'server.threadPool': 1
    4246                    'server.logToScreen': False, 
    4347                    'server.environment': "production", 
    4448                    'sessionFilter.on' : True, 
    45                     'sessionFilter.default.on' : False
    46                     'sessionFilter.storagePath' : 'tmpSessionTestData' 
     49                    'sessionFilter.cacheTimeout' : 60
     50                    'sessionFilter.storagePath' : tmpFolder 
    4751                    }, 
    4852               '/ram'   : { 'sessionFilter.ram.on'   : True, 'sessionFilter.ram.storageType'   : 'ram'   }, 
     
    7781cherrypy.config.update(server_conf.copy()) 
    7882 
    79 class TutorialTest(unittest.TestCase): 
     83import threading 
    8084 
    81     persistantCookies = {} 
     85class SessionFilterTest(unittest.TestCase): 
    8286 
    83     def __testStorageType(self, storageType, startCount = 1, iterations = 0): 
    84          
     87    persistantCookies = [] 
     88 
     89    def __testStorageType(self, storageType, startCount = 1, iterations = 4): 
    8590        #cherrypy.config.update({"sessionFilter.storageType": storageType}) 
    8691         
     
    103108    def testAnydbSessions(self): 
    104109        self.__testStorageType('anydb') 
    105  
     110    
     111    def testThreadSafety(self, storageType = 'ram'): 
     112        for z in range(3): 
     113            try: 
     114                threading.Thread(target = self.__testStorageType, args = ('ram', 1, 4)).start() 
     115            except: 
     116                pass 
     117     
    106118    ''' 
    107119    def testSqlObjectSession(self): 
    108120        self.__testStorageType('sqlobject') 
    109121    ''' 
    110      
     122 
    111123if __name__ == "__main__": 
    112124    try: 
    113         os.mkdir('tmpSessionTestData') 
    114         for file in os.listdir('tmpSessionTestData'): 
    115             os.unlink(os.path.join('tmpSessionTestData', file)) 
     125        os.mkdir(tmpFolder) 
    116126    except OSError: 
    117127        pass 
     128     
    118129    cherrypy.server.start(initOnly=True) 
    119     unittest.main() 
     130    try: 
     131        unittest.main() 
     132    except SystemExit: 
     133        pass 
     134        #shutil.rmtree(tmpFolder) 
     135        #os.rmdir(tmpFolder) 

Hosted by WebFaction

Log in as guest/cpguest to create tickets