Changeset 1193
- Timestamp:
- 07/10/06 01:25:49
- Files:
-
- trunk/cherrypy/_cprequest.py (modified) (3 diffs)
- trunk/cherrypy/lib/profiler.py (modified) (2 diffs)
- trunk/cherrypy/test/helper.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cprequest.py
r1188 r1193 9 9 from cherrypy import _cpcgifs 10 10 from cherrypy._cperror import format_exc, bare_error 11 from cherrypy.lib import http , profiler11 from cherrypy.lib import http 12 12 13 13 … … 139 139 self.handler = None 140 140 141 # Set up the profiler if requested.142 conf = cherrypy.config.get143 if conf("profiling.on", False):144 p = getattr(cherrypy, "profiler", None)145 if p is None:146 ppath = conf("profiling.path", "")147 p = cherrypy.profiler = profiler.Profiler(ppath)148 cherrypy.profiler.run(self._run)149 else:150 self._run()151 152 if self.method == "HEAD":153 # HEAD requests MUST NOT return a message-body in the response.154 cherrypy.response.body = []155 156 log_access = cherrypy.config.get("log_access", cherrypy.log_access)157 if log_access:158 log_access()159 160 return cherrypy.response161 162 def _run(self):163 141 try: 164 142 self.process_request_line() … … 198 176 raise 199 177 self.handle_error(sys.exc_info()) 178 179 if self.method == "HEAD": 180 # HEAD requests MUST NOT return a message-body in the response. 181 cherrypy.response.body = [] 182 183 log_access = cherrypy.config.get("log_access", cherrypy.log_access) 184 if log_access: 185 log_access() 186 187 return cherrypy.response 200 188 201 189 def respond(self, path_info): trunk/cherrypy/lib/profiler.py
r1095 r1193 78 78 path = os.path.join(self.path, "cp_%04d.prof" % self.count) 79 79 prof = profile.Profile() 80 prof.runcall(func, *args)80 result = prof.runcall(func, *args) 81 81 prof.dump_stats(path) 82 return result 82 83 83 84 def statfiles(self): … … 128 129 129 130 131 class make_app: 132 def __init__(self, nextapp, path=None): 133 """Make a WSGI middleware app which wraps 'nextapp' with profiling.""" 134 self.nextapp = nextapp 135 self.profiler = Profiler(path) 136 137 def __call__(self, environ, start_response): 138 def gather(): 139 result = [] 140 for line in self.nextapp(environ, start_response): 141 result.append(line) 142 return result 143 return self.profiler.run(gather) 144 145 130 146 def serve(path=None, port=8080): 131 147 import cherrypy trunk/cherrypy/test/helper.py
r1188 r1193 24 24 25 25 import cherrypy 26 from cherrypy.lib import http 26 from cherrypy.lib import http, profiler 27 27 import webtest 28 28 … … 122 122 if base == "/": 123 123 base = "" 124 apps.append((base, _cpwsgi.wsgiApp)) 124 if conf.get("profiling.on", False): 125 apps.append((base, profiler.make_app(_cpwsgi.wsgiApp))) 126 else: 127 apps.append((base, _cpwsgi.wsgiApp)) 125 128 ## # We could use the following line, but it breaks test_tutorials 126 129 ## apps.append((base, _cpwsgi.make_app(app)))

