Changeset 148
- Timestamp:
- 02/13/05 08:24:13
- Files:
-
- trunk/cherrypy/_cpserver.py (modified) (2 diffs)
- trunk/cherrypy/_cpthreadinglocal.py (added)
- trunk/cherrypy/_cputil.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cpserver.py
r131 r148 33 33 """ 34 34 35 import cpg, thread, _cputil, _cpconfig, _cphttpserver, time 35 import cpg, thread, _cputil, _cpconfig, _cphttpserver, time, _cpthreadinglocal 36 36 37 37 def start(configFile = None, parsedConfigFile = None, configMap = {}, initOnly = 0): … … 72 72 # Create request and response object (the same objects will be used 73 73 # throughout the entire life of the webserver) 74 cpg.request = _cp util.ThreadAwareClass()75 cpg.response = _cp util.ThreadAwareClass()74 cpg.request = _cpthreadinglocal.local() 75 cpg.response = _cpthreadinglocal.local() 76 76 # Create threadData object as a thread-specific all-purpose storage 77 cpg.threadData = _cp util.ThreadAwareClass()77 cpg.threadData = _cpthreadinglocal.local() 78 78 79 79 # Initialize a few global variables trunk/cherrypy/_cputil.py
r108 r148 41 41 pass 42 42 43 class ThreadAwareClass:44 """ A thread-safe class for storing/retrieving45 thread-specific variables """46 47 def __init__(self):48 self.__dict__['threadMap'] = {} # Used to store variables49 50 def __setattr__(self, name, value):51 id = thread.get_ident()52 if not self.__dict__['threadMap'].has_key(id):53 self.__dict__['threadMap'][id] = {}54 self.threadMap[id][name] = value55 56 def __getattr__(self, name):57 id = thread.get_ident()58 return self.__dict__['threadMap'][id][name]59 60 43 def getSpecialFunction(name): 61 44 """ Return the special function """

