~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/middleware/profile.py

[r=bac][bug=698305] Return a 404 instead of a traceback when the user
        asks for an invalid revision.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
'''Profiling middleware for paste.'''
2
 
import cgi
 
1
"""Profiling middleware for Paste."""
 
2
 
3
3
import threading
4
4
 
5
5
from bzrlib.lsprof import profile
6
6
 
 
7
 
7
8
class LSProfMiddleware(object):
8
 
    '''Paste middleware for profiling with lsprof.'''
 
9
    """Paste middleware for profiling with lsprof."""
9
10
 
10
11
    def __init__(self, app, global_conf=None):
11
12
        self.app = app
26
27
        try:
27
28
            ret, stats = profile(self.__run_app, environ, start_response)
28
29
            self.__count += 1
29
 
            stats.save("%d-stats.callgrind" % self.__count, format="callgrind")
 
30
            stats.save("%d-stats.callgrind" % (self.__count,), format="callgrind")
30
31
            return ret
31
32
        finally:
32
33
            self.lock.release()
33