1
"""Profiling middleware for Paste."""
5
from bzrlib.lsprof import profile
8
class LSProfMiddleware(object):
9
"""Paste middleware for profiling with lsprof."""
11
def __init__(self, app, global_conf=None):
13
self.lock = threading.Lock()
16
def __run_app(self, environ, start_response):
17
app_iter = self.app(environ, start_response)
21
if getattr(app_iter, 'close', None):
24
def __call__(self, environ, start_response):
28
ret, stats = profile(self.__run_app, environ, start_response)
30
stats.save("%d-stats.callgrind" % (self.__count,), format="callgrind")