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

Changeset 148

Show
Ignore:
Timestamp:
02/13/05 08:24:13
Author:
rdelon
Message:

Fixed Ticket #106
Removed ThreadAwareClass? and included a backport of python-2.4's threading.local() implementation

Files:

Legend:

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

    r131 r148  
    3333""" 
    3434 
    35 import cpg, thread, _cputil, _cpconfig, _cphttpserver, time 
     35import cpg, thread, _cputil, _cpconfig, _cphttpserver, time, _cpthreadinglocal 
    3636 
    3737def start(configFile = None, parsedConfigFile = None, configMap = {}, initOnly = 0): 
     
    7272    # Create request and response object (the same objects will be used 
    7373    #   throughout the entire life of the webserver) 
    74     cpg.request = _cputil.ThreadAwareClass() 
    75     cpg.response = _cputil.ThreadAwareClass() 
     74    cpg.request = _cpthreadinglocal.local() 
     75    cpg.response = _cpthreadinglocal.local() 
    7676    # Create threadData object as a thread-specific all-purpose storage 
    77     cpg.threadData = _cputil.ThreadAwareClass() 
     77    cpg.threadData = _cpthreadinglocal.local() 
    7878 
    7979    # Initialize a few global variables 
  • trunk/cherrypy/_cputil.py

    r108 r148  
    4141    pass 
    4242 
    43 class ThreadAwareClass: 
    44     """ A thread-safe class for storing/retrieving 
    45         thread-specific variables """ 
    46  
    47     def __init__(self): 
    48         self.__dict__['threadMap'] = {} # Used to store variables 
    49  
    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] = value 
    55  
    56     def __getattr__(self, name): 
    57         id = thread.get_ident() 
    58         return self.__dict__['threadMap'][id][name] 
    59  
    6043def getSpecialFunction(name): 
    6144    """ Return the special function """ 

Hosted by WebFaction

Log in as guest/cpguest to create tickets