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

Changeset 989

Show
Ignore:
Timestamp:
03/02/06 02:05:04
Author:
fumanchu
Message:

New Engine.response_class attribute (which allows a new -null switch for benchmark.py, to show how much of the request is spent in the HTTP server as opposed to the Request object).

Files:

Legend:

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

    r980 r989  
    2121     
    2222    request_class = _cphttptools.Request 
     23    response_class = _cphttptools.Response 
    2324     
    2425    def __init__(self): 
     
    187188                               remoteHost, scheme) 
    188189        cherrypy.serving.request = r 
    189         cherrypy.serving.response = _cphttptools.Response() 
     190        cherrypy.serving.response = self.response_class() 
    190191        return r 
    191192 
  • trunk/cherrypy/test/bench_mp.conf

    r988 r989  
    77<Location /> 
    88    SetHandler python-program 
    9     PythonFixupHandler cherrypy.test.benchmark::startup 
     9     
     10    <IfDefine !nullreq> 
     11        PythonFixupHandler cherrypy.test.benchmark::startup 
     12    </IfDefine> 
     13    <IfDefine nullreq> 
     14        PythonFixupHandler cherrypy.test.benchmark::startup_null 
     15    </IfDefine> 
     16     
    1017    PythonHandler modpython_gateway::handler 
    1118    PythonOption application cherrypy._cpwsgi::wsgiApp 
  • trunk/cherrypy/test/benchmark.py

    r988 r989  
    1010 
    1111import cherrypy 
     12from cherrypy.lib import httptools 
    1213 
    1314 
     
    212213 
    213214 
     215class NullRequest: 
     216    """A null HTTP request class, returning 204 and an empty body.""" 
     217     
     218    def __init__(self, remoteAddr, remotePort, remoteHost, scheme="http"): 
     219        pass 
     220     
     221    def close(self): 
     222        pass 
     223     
     224    def run(self, requestLine, headers, rfile): 
     225        cherrypy.response.status = "204 No Content" 
     226        cherrypy.response.header_list = [("Content-Type", 'text/html'), 
     227                                         ("Server", "Null CherryPy"), 
     228                                         ("Date", httptools.HTTPDate()), 
     229                                         ("Content-Length", "0"), 
     230                                         ] 
     231        cherrypy.response.body = [""] 
     232        return cherrypy.response 
     233 
     234 
     235class NullResponse: 
     236    pass 
     237 
     238 
    214239started = False 
    215240def startup(req=None): 
     
    218243    if not started: 
    219244        started = True 
     245        cherrypy.server.start(init_only=True, server_class=None) 
     246    return 0 # apache.OK 
     247 
     248def startup_null(req=None): 
     249    """Start the CherryPy app server in NULL 'serverless' mode (for WSGI).""" 
     250    global started 
     251    if not started: 
     252        started = True 
     253        cherrypy.server.request_class = NullRequest 
     254        cherrypy.server.response_class = NullResponse 
    220255        cherrypy.server.start(init_only=True, server_class=None) 
    221256    return 0 # apache.OK 
     
    242277        try: 
    243278            mpconf = os.path.join(curdir, "bench_mp.conf") 
    244             read_process("apache", "-k start -f %s" % mpconf) 
     279            if "-null" in sys.argv: 
     280                # Pass the null option through Apache 
     281                read_process("apache", "-k start -D nullreq -f %s" % mpconf) 
     282            else: 
     283                read_process("apache", "-k start -f %s" % mpconf) 
    245284            run() 
    246285        finally: 
    247286            os.popen("apache -k stop") 
    248287    else: 
     288        if "-null" in sys.argv: 
     289            cherrypy.server.request_class = NullRequest 
     290            cherrypy.server.response_class = NullResponse 
     291         
    249292        # This will block 
    250293        cherrypy.server.start_with_callback(run) 

Hosted by WebFaction

Log in as guest/cpguest to create tickets