Changeset 989
- Timestamp:
- 03/02/06 02:05:04
- Files:
-
- trunk/cherrypy/_cpengine.py (modified) (2 diffs)
- trunk/cherrypy/test/bench_mp.conf (modified) (1 diff)
- trunk/cherrypy/test/benchmark.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cpengine.py
r980 r989 21 21 22 22 request_class = _cphttptools.Request 23 response_class = _cphttptools.Response 23 24 24 25 def __init__(self): … … 187 188 remoteHost, scheme) 188 189 cherrypy.serving.request = r 189 cherrypy.serving.response = _cphttptools.Response()190 cherrypy.serving.response = self.response_class() 190 191 return r 191 192 trunk/cherrypy/test/bench_mp.conf
r988 r989 7 7 <Location /> 8 8 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 10 17 PythonHandler modpython_gateway::handler 11 18 PythonOption application cherrypy._cpwsgi::wsgiApp trunk/cherrypy/test/benchmark.py
r988 r989 10 10 11 11 import cherrypy 12 from cherrypy.lib import httptools 12 13 13 14 … … 212 213 213 214 215 class 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 235 class NullResponse: 236 pass 237 238 214 239 started = False 215 240 def startup(req=None): … … 218 243 if not started: 219 244 started = True 245 cherrypy.server.start(init_only=True, server_class=None) 246 return 0 # apache.OK 247 248 def 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 220 255 cherrypy.server.start(init_only=True, server_class=None) 221 256 return 0 # apache.OK … … 242 277 try: 243 278 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) 245 284 run() 246 285 finally: 247 286 os.popen("apache -k stop") 248 287 else: 288 if "-null" in sys.argv: 289 cherrypy.server.request_class = NullRequest 290 cherrypy.server.response_class = NullResponse 291 249 292 # This will block 250 293 cherrypy.server.start_with_callback(run)

